InfluxDB: Install Telegraf on Linux to collect metric data

"Telegraf is an open source server agent that helps you collect metrics from your stacks, sensors, and systems."
We can use Telegraf to collect metric data and save it to InfluxDB.
I'll use the installation script from the Influx web site:
# curl --silent --location -O \
https://repos.influxdata.com/influxdata-archive.key \
&& echo "943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 influxdata-archive.key" \
| sha256sum -c - && cat influxdata-archive.key \
| gpg --dearmor \
| sudo tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null \
&& echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' \
| sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf
After installation, Telegraf has to be configured. The config file is /etc/telegraf/telegraf.conf
, and these parameters should be configured:
- Metric section
The metric section starts with
[[outputs.influxdb_v2]]
Below that, we'll have to set some additional parameters:
- URLs: the network address for the InfluxDB databae
- Token: it will allow us to write the data into the InfluxDB database
- Organisation: it's the value we provided at installation of InfluxDB
- Bucket: the target where metric data is written into. It can be used to divide several metric targets
After configuration, it will look like that:
[[outputs.influxdb_v2]]
urls = ["https://influxdb.martinscloud.com"]
token = "WaN2I77ebKgXpLfuRWZKy7sgEwa-qt0BMZZhZoccMpUpog6fCUqxvTgLJAemmZTSrg_vHjNZ9fqpAssShHDLZg=="
organization = "private"
bucket = "telegraf"
That's quite enough for now. Let's enable and start Telegraf:
# systemctl enable --now telegraf
When we now look into the InfluxDB database and the bucket we used for configuration, we can already see data:

If you're interested, here's the Telegraf documentation.