{"id":2895,"date":"2019-05-09T22:56:15","date_gmt":"2019-05-09T19:56:15","guid":{"rendered":"https:\/\/kifarunix.com\/?p=2895"},"modified":"2019-05-09T22:56:16","modified_gmt":"2019-05-09T19:56:16","slug":"install-and-configure-telegraf-on-freebsd-12","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-and-configure-telegraf-on-freebsd-12\/","title":{"rendered":"Install and Configure Telegraf on FreeBSD 12"},"content":{"rendered":"\n<p>Welcome to our guide on how to install and configure Telegraf on FreeBSD 12. If you are looking at collecting and monitoring FreeBSD 12 system metrics, then you might want to use the powerful TIG stack monitoring and visualization tool. In this case, you can install Telegraf agent for collecting these metrics for analysis. <\/p>\n\n\n\n<p>We have covered the installation and setup of TIG stack on Fedora 30 in our previous guide. See the link below.<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-setup-tig-stack-on-fedora-30\/\" target=\"_blank\">Install and Setup TIG Stack on Fedora 30<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install and Configure Telegraf on FreeBSD 12<\/h2>\n\n\n\n<p>Telegraf is already available on the default FreeBSD 12 repositories and hence can be installed directly using the PKG package manager.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Update and Upgrade System Packages<\/h3>\n\n\n\n<p>Before you can run the installation of Telegraf, ensure that your system packages are re-synchronized to the latest versions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg update<br>pkg upgrade<\/code><\/pre>\n\n\n\n<p>Verify the availability of the Telegraf package on the FreeBSD 12 repos.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>pkg search telegraf<br>telegraf-1.10.1                Time-series data collection<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Telegraf on FreeBSD 12<\/h3>\n\n\n\n<p>To install Telegraf on FreeBSD 12, run the command below;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pkg install telegraf\nUpdating FreeBSD repository catalogue...\nFreeBSD repository is up to date.\nAll repositories are up to date.\nThe following 1 package(s) will be affected (of 0 checked):\n\nNew packages to be INSTALLED:\n\ttelegraf: 1.10.1\n\nNumber of packages to be installed: 1\n\nThe process will require 72 MiB more space.\n24 MiB to be downloaded.\n\nProceed with this action? [y\/N]: y<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Start and Enable Telegraf<\/h3>\n\n\n\n<p>Once the installation is done, enable Telegraf to run on system boot and then start it.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysrc telegraf_enable=yes\ntelegraf_enable:  -> yes<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>service telegraf start\nStarting telegraf<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Configure Telegraf on FreeBSD 12<\/h3>\n\n\n\n<p>Configuration of Telegraf is similar across various systems. However, the location of the default configuration file varies with the OS variants. For the case of FreeBSD 12, the default Telegraf configuration file is located under, <strong>\/usr\/local\/etc\/telegraf.conf<\/strong>.<\/p>\n\n\n\n<p>As you already know, Telegraf supports various input as well as output plugins. In a basic configuration, we will configure Telegraf to collect a number of system metrics and ingest them on InfluxDB time series database.<\/p>\n\n\n\n<p>Hence, to create a configuration file with specific metrics input plugins, create a new configuration file using the telegraf command as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>mv \/usr\/local\/etc\/telegraf.conf \/usr\/local\/etc\/telegraf.conf.bak<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>telegraf config -input-filter cpu:mem:swap:system:processes -output-filter influxdb > \/usr\/local\/etc\/telegraf.conf<\/code><\/pre>\n\n\n\n<p>Next, edit the configuration file to define the InfluxDB (output plugin) connection details.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/usr\/local\/etc\/telegraf.conf<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n[[outputs.influxdb]]\n  urls = [\"http:\/\/&lt;Influx-DB-Host-IP>:8086\"]\n  database = \"&lt;influxdb-database>\"\n  username = \"&lt;influxdb-user>\"\n  password = \"&lt;Password>\"\n...<\/code><\/pre>\n\n\n\n<p>Replace the <strong>&lt;Influx-DB-Host-IP><\/strong>, <strong>&lt;influxdb-database><\/strong>, <strong>&lt;influxdb-user><\/strong> and <strong>&lt;Password><\/strong> with your connection details appropriately. Your configuration file in basic form should look like;<\/p>\n\n\n\n<p>Next, ensure that there is a connection to the InfluxDB from the Telegraf agent server host, FreeBSD 12 in this case. You can test this with telnet, as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>telnet 192.168.0.107 8086\nTrying 192.168.0.107\u2026\nConnected to 192.168.0.107.\nEscape character is '^]'.<\/code><\/pre>\n\n\n\n<p>Restart Telegraf and run some basic configuration test.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>service telegraf restart<\/code><\/pre>\n\n\n\n<p>To run configuration test;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>telegraf -config \/usr\/local\/etc\/telegraf.conf -test<\/code><\/pre>\n\n\n\n<p>Next, Login to InfluxDB and verify that system metrics from Telegraf agent are received. For example to check the CPU usage metrics;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>influx<br>Connected to http:\/\/localhost:8086 version 1.7.6<br>InfluxDB shell version: 1.7.6<br>Enter an InfluxQL query<br>> use telegraf<br>Using database telegraf<br>> auth<br>username: telegraf<br>password: <strong>StrongP@SS<\/strong> <br>> <strong>select * from cpu where host='freebsd12.example.com' and dc='freebsd12' limit 5<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>name: cpu\ntime                cpu       dc        host                  usage_guest usage_guest_nice usage_idle        usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system        usage_user\n----                ---       --        ----                  ----------- ---------------- ----------        ------------ --------- ---------- ------------- ----------- ------------        ----------\n1557396600000000000 cpu-total freebsd12 freebsd12.example.com 0           0                99.13589945011783 0            0         0          0             0           0.4713275726630008  0.3927729772191673\n1557396600000000000 cpu0      freebsd12 freebsd12.example.com 0           0                99.13589945011783 0            0         0          0             0           0.4713275726630008  0.3927729772191673\n1557396610000000000 cpu-total freebsd12 freebsd12.example.com 0           0                99.84251968503936 0            0         0          0             0           0.15748031496062992 0\n1557396610000000000 cpu0      freebsd12 freebsd12.example.com 0           0                99.84251968503936 0            0         0          0             0           0.15748031496062992 0\n1557396620000000000 cpu-total freebsd12 freebsd12.example.com 0           0                99.84301412872841 0            0         0          0             0           0.15698587127158556 0<\/code><\/pre>\n\n\n\n<p>Well, that looks good and that is just it about how to install and configure Telegraf on FreeBSD 12.<\/p>\n\n\n\n<p>You can also check our related guides by following the links below;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-telegraf-on-fedora-30-fedora-29\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install Telegraf on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-influxdb-on-fedora-30-fedora-29\/\" target=\"_blank\">Install InfluxDB on Fedora 30\/Fedora 29<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-grafana-monitoring-tool-on-fedora-29\/\">Install Grafana Monitoring Tool on Fedora 29<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-grafana-metrics-monitoring-tool-on-debian-9\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install Grafana Metrics Monitoring Tool on Debian 9<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-grafana-data-visualization-tool-on-ubuntu-18-04\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install Grafana Data Visualization Tool on Ubuntu 18.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to our guide on how to install and configure Telegraf on FreeBSD 12. If you are looking at collecting and monitoring FreeBSD 12 system<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,933,939],"tags":[278,935,940],"class_list":["post-2895","post","type-post","status-publish","format-standard","hentry","category-monitoring","category-telegraf","category-tig-stack","tag-freebsd-12","tag-telegraf","tag-tig-stack","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2895"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=2895"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2895\/revisions"}],"predecessor-version":[{"id":2903,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/2895\/revisions\/2903"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=2895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=2895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=2895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}