How to Install Telegraf on Raspbian OS

Huzeifa DawoodHuzeifa Dawood
2 min read

What is Telegraf?

Telegraf is a server-based agent for collecting and sending metrics from all types of systems. For example, Telegraf can gather your Raspberry Pi's system data such as CPU, memory and disk usage and send it to a database of your choice.

The Raspbian OS repository doesn't include the latest version of Telegraf. The following steps will show you how to install the latest version of Telegraf on Raspbian OS.

Step 1: Download the Influx Data repo key and add it to the APT package manager.

wget -qO- https://repos.influxdata.com/influxdb.key | sudo tee /etc/apt/trusted.gpg.d/influxdb.asc >/dev/null
source /etc/os-release
echo "deb https://repos.influxdata.com/debian ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list

Step 3: Update APT and install Telegraf

sudo apt-get update && sudo apt-get install telegraf -y

You have now successfully installed Telegraf!

Note:

  • The telegraf.conf file is available in the /etc/telegraf directory
  • Global variables such as Influx Tokens are defined in the /etc/default/telegraf file.

Installation Script

Run the install script to install Telegraf in one keystroke.

#!/usr/bin/env bash
set -e

wget -qO- https://repos.influxdata.com/influxdb.key | sudo tee /etc/apt/trusted.gpg.d/influxdb.asc >/dev/null
source /etc/os-release
echo "deb https://repos.influxdata.com/debian ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install telegraf -y

Copy and paste the above lines to a file named install_telegraf.sh

Make the file executable.

chmod +x install_telegraf.sh

Finally, run the install script.

./install_telegraf.sh
0
Subscribe to my newsletter

Read articles from Huzeifa Dawood directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Huzeifa Dawood
Huzeifa Dawood