Install Telegraf and configure for InfluxDB

Video Lecture

Install Telegraf and configure for InfluxDB 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

Navigate to the telegraf config folder and backup the existing config.

cd /etc/telegraf/
mv telegraf.conf telegraf.conf.default

Create a new telegraf.conf

rm telegraf.conf
sudo nano telegraf.conf

and copy and paste script below into new telegraf.conf

# Global Agent Configuration
[agent]
  hostname = "127.0.0.1"
  flush_interval = "15s"
  interval = "15s"


# Input Plugins
[[inputs.cpu]]
    percpu = true
    totalcpu = true
    collect_cpu_time = false
    report_active = false
[[inputs.disk]]
    ignore_fs = ["tmpfs", "devtmpfs", "devfs"]
[[inputs.io]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.system]]
[[inputs.swap]]
[[inputs.netstat]]
[[inputs.processes]]
[[inputs.kernel]]

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

Save, restart Telegraf, and check status.

sudo service telegraf restart
sudo service telegraf status

Check that Telegraf is working with the new config by printing some values.

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

See the video for an example of exploring the new data source in Grafana.