Install and Configure Telegraf on FreeBSD 12

|
Published:
|
|

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.

We have covered the installation and setup of TIG stack on Fedora 30 in our previous guide. See the link below.

Install and Setup TIG Stack on Fedora 30

Install and Configure Telegraf on FreeBSD 12

Telegraf is already available on the default FreeBSD 12 repositories and hence can be installed directly using the PKG package manager.

Update and Upgrade System Packages

Before you can run the installation of Telegraf, ensure that your system packages are re-synchronized to the latest versions.

pkg update
pkg upgrade

Verify the availability of the Telegraf package on the FreeBSD 12 repos.

pkg search telegraf
telegraf-1.10.1 Time-series data collection

Install Telegraf on FreeBSD 12

To install Telegraf on FreeBSD 12, run the command below;

pkg install telegraf
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
	telegraf: 1.10.1

Number of packages to be installed: 1

The process will require 72 MiB more space.
24 MiB to be downloaded.

Proceed with this action? [y/N]: y

Start and Enable Telegraf

Once the installation is done, enable Telegraf to run on system boot and then start it.

sysrc telegraf_enable=yes
telegraf_enable:  -> yes
service telegraf start
Starting telegraf

Configure Telegraf on FreeBSD 12

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, /usr/local/etc/telegraf.conf.

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.

Hence, to create a configuration file with specific metrics input plugins, create a new configuration file using the telegraf command as shown below.

mv /usr/local/etc/telegraf.conf /usr/local/etc/telegraf.conf.bak
telegraf config -input-filter cpu:mem:swap:system:processes -output-filter influxdb > /usr/local/etc/telegraf.conf

Next, edit the configuration file to define the InfluxDB (output plugin) connection details.

vim /usr/local/etc/telegraf.conf
...
[[outputs.influxdb]]
  urls = ["http://<Influx-DB-Host-IP>:8086"]
  database = "<influxdb-database>"
  username = "<influxdb-user>"
  password = "<Password>"
...

Replace the <Influx-DB-Host-IP>, <influxdb-database>, <influxdb-user> and <Password> with your connection details appropriately. Your configuration file in basic form should look like;

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.

telnet 192.168.0.107 8086
Trying 192.168.0.107…
Connected to 192.168.0.107.
Escape character is '^]'.

Restart Telegraf and run some basic configuration test.

service telegraf restart

To run configuration test;

telegraf -config /usr/local/etc/telegraf.conf -test

Next, Login to InfluxDB and verify that system metrics from Telegraf agent are received. For example to check the CPU usage metrics;

influx
Connected to http://localhost:8086 version 1.7.6
InfluxDB shell version: 1.7.6
Enter an InfluxQL query
> use telegraf
Using database telegraf
> auth
username: telegraf
password: StrongP@SS
> select * from cpu where host='freebsd12.example.com' and dc='freebsd12' limit 5
name: cpu
time                cpu       dc        host                  usage_guest usage_guest_nice usage_idle        usage_iowait usage_irq usage_nice usage_softirq usage_steal usage_system        usage_user
----                ---       --        ----                  ----------- ---------------- ----------        ------------ --------- ---------- ------------- ----------- ------------        ----------
1557396600000000000 cpu-total freebsd12 freebsd12.example.com 0           0                99.13589945011783 0            0         0          0             0           0.4713275726630008  0.3927729772191673
1557396600000000000 cpu0      freebsd12 freebsd12.example.com 0           0                99.13589945011783 0            0         0          0             0           0.4713275726630008  0.3927729772191673
1557396610000000000 cpu-total freebsd12 freebsd12.example.com 0           0                99.84251968503936 0            0         0          0             0           0.15748031496062992 0
1557396610000000000 cpu0      freebsd12 freebsd12.example.com 0           0                99.84251968503936 0            0         0          0             0           0.15748031496062992 0
1557396620000000000 cpu-total freebsd12 freebsd12.example.com 0           0                99.84301412872841 0            0         0          0             0           0.15698587127158556 0

Well, that looks good and that is just it about how to install and configure Telegraf on FreeBSD 12.

You can also check our related guides by following the links below;

Install Telegraf on Fedora 30/Fedora 29

Install InfluxDB on Fedora 30/Fedora 29

Install Grafana Monitoring Tool on Fedora 29

Install Grafana Metrics Monitoring Tool on Debian 9

Install Grafana Data Visualization Tool on Ubuntu 18.04

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment