Telegraf - zbrewer/homelab GitHub Wiki

Telegraf can export a variety of metrics to a variety of data sinks. In my homelab, I use it to export temperatures from Proxmox nodes to InfluxDB for inclusion on Grafana dashboards.

Installation

Lm-sensors

Before setting up Telegraf on a Proxmox node, make sure lm-sensors is installed and configured:

$ apt-get install lm-sensors
$ sensors-detect

Running sensors should now output sensor readings.

Mellanox Firmware Tools

If installing on a node with a Mellanox NIC that should be monitored, Mellanox Framework Tools should also be installed and configured first. The install and initial configuration instructions can be found here.

In order to start at boot, copy the mellanox-tools.service file to the /etc/systemd/system/ directory and run the following commands to load and enable the service at boot:

$ systemctl daemon-reload
$ systemctl enable --now mellanox-tools.service

Telegraf

Install Telegraf on the Proxmox node with the following commands:

$ wget -q https://repos.influxdata.com/influxdata-archive_compat.key
$ echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
$ echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
$ apt-get update
$ apt-get install telegraf

Now make sure the correct telegraf config file is copied over to /etc/telegraf/telegraf.conf. Make sure to replace the API token placeholder for InfluxDB with a token that has write permissions. Then run systemd enable --now telegraf to start telegraf and make sure it restarts at boot. Metrics should now be available in InfluxDB and viewable in the query builder.

Note: If exporting metrics from the Proxmox built-in external metric server integration and Telegraf, metric conflicts may exist (both try to write different values to the same metric for the same host). To avoid this, ensure that duplicate metrics aren't exported, set the hostname in telegraf.conf to overwrite the system hostname, or write data to different buckets.

If using telegraf to export Mellanox NIC temperatures on a node with the Mellanox Firmware Tools installed, copy the sudoers file to /etc/sudoers.d/telegraf in order to enable telegraf to have access to mget_temp without a password. The device ID in the exec command in the telegraf config might also have to be changed to match the installed device. Mellanox devices can be listed with mst status and the exec command can be tested from the command line with the new device ID before updating the telegraf config.

Reload Config File

After making a change to the telegraf config, reload the service with systemctl restart telegraf.

Updates

Updates are accomplished through the typical apt package management.