Install Telegraf and configure for InfluxDB

Video Lecture

Install Telegraf and configure for InfluxDB Install Telegraf and configure for InfluxDB

Description

Now to install the Telegraf agent and configure the output plugin to save data into the InfluxDB.

sudo apt install telegraf -y

Start Telegraf and ensure it starts in case of reboot.

sudo systemctl start telegraf
sudo systemctl status telegraf

Ensure it auto starts in case of system, reboot

sudo systemctl enable telegraf

Look at the telegraf configuration file

sudo nano /etc/telegraf/telegraf.conf

Leave all the defaults, but ensure your outputs.influxdb section has the following.

# Output Plugin InfluxDB
[[outputs.influxdb]]
  database = "telegraf"
  urls = [ "http://127.0.0.1:8086" ]
  username = "telegraf"
  password = "password"

Check that the Telegraf configuration is valid.

sudo telegraf -test -config /etc/telegraf/telegraf.conf

Now, create a user that the Telegraf process can use to push data to InfluxDB

influx
> create user telegraf with password 'password'
> show users
> grant ALL on telegraf to telegraf
> show GRANTS for telegraf
> quit

Restart Telegraf, and check its status.

sudo service telegraf restart
sudo service telegraf status

Examine the Influxdb changes

influx
use telegraf
show measurements
quit

Go back into Grafana and explore the new data.

InfluxDB Authentication & Authorization