Monitoring Your Raspberry Pi System using InfluxDB Telegraf

This guide will show you how to monitor your Raspberry Pi system using InfluxDB Telegraf. You can collect metrics from the Raspberry Pi board (CPU usage, memory usage, disk usage, system load, CPU and GPU temperatures, and other useful data) to monitor the system using InfluxDB Telegraf. Telegraf is InfluxData’s data collection agent for collecting and reporting metrics.

Monitoring Your Raspberry Pi System using InfluxDB Telegraf


Before proceeding you must have InfluxDB installed on your Raspberry Pi. Follow the next tutorial:

Raspberry Pi Monitoring Template

There is an InfluxDB template that can be used to monitor your Raspberry Pi Linux system. An InfluxDB template is a prepackaged set of InfluxDB configurations that contain everything from dashboards and Telegraf configurations to notifications and alerts.

Templates reduce the setup time by giving you resources that are already configured for your use case. In this case, you’ll get a set of configurations that are ready to use to monitor your Raspberry Pi. To learn more about InfluxDB templates, you can check the following link:

We’ll use the Raspberry Pi Monitoring template that includes the following:

  • one bucket: rasp-pi (7d retention)
  • labels: raspberry-pi + Telegraf plugin labels
    • Diskio input plugin
    • Mem input plugin
    • Net input plugin
    • Processes input plugin
    • Swap input plugin
    • System input plugin
  • one Telegraf configuration
  • one dashboard: Raspberry Pi System
  • two variables: bucket and linux_host

Follow the next instructions to install the Raspberry Pi Monitoring template.

Getting an InfluxDB Token

You need to get an InfluxDB token to be able to install the Raspberry Pi Monitoring template using Influx CLI (command line interface).

Go to your InfluxDB Interface:


Once you’re on InfluxDB, on the left sidebar click on Data/Load Data and then, select the API Tokens tab. Click on the + Generate API Token to generate a new API Token. We’ll generate an All Access API Token.

InfluxDB Generate All Access API Token

Give a description to the API Token (for example Raspberry-Pi).

Raspberry Pi All Access API Token

The new API Token should be on the list:

Raspberry Pi API Token (list of tokens)

Click on the API Token name to check the API token. You can save it in a safe place because you’ll need it in a moment.

Raspberry Pi Token

Installing Influx CLI

Influx CLI is InfluxDB command line interface that contains commands to manage many aspects of InfluxDB, including buckets, organizations, users, tasks, etc. It should be automatically installed when you install InfluxDB.

Provide required authentication credentials

To avoid having to pass your InfluxDB host, API token, and organization with each command, you can store them in an influx CLI configuration (config). For that, you need to use the influx config create command and pass your information.

First, edit the following command with your information:

influx config create --config-name influx-config \
  --host-url http://YOUR_RASPBERRY_PI_IP_ADDRESS:8086 \
  --org <your-org> \
  --token <your-auth-token> \
  • Replace YOUR_RASPBERRY_PI_IP_ADDRESS with your Pi’s IP address.
  • Replace <your-org> with your InfluxDB organization name
  • Replace the <your-auth-token> with the API token you got in the previous step.

For example, in my case, the command looks as follows:

influx config create --config-name influx-config \
  --host-url \
  --org RNT \
  --token v_od_mG--9_srf_OnaaODihPDX34suToP7XEH47v6x77CMxakZaoYHzF7Ec9mLT-CuXXXXXXXXXXXXXXXXXvQCSSw== \

Applying the Raspberry Pi Template

Now, run the following command to apply the Raspberry Pi template.

influx apply -u

Installing Telegraf

Run the following commands sequentially to install Telegraf:

wget -q
echo '23a1c8836f0afc5ed24e0486339d7cc8f6790b83886c4c96995b88a061c5bb5d influxdb.key' | sha256sum -c && cat influxdb.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdb.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdb.gpg] stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf

Now, you need to add the following environment variables to your Telegraf environment:

  • INFLUX_TOKEN: Your InfluxDB Cloud API token
  • INFLUX_ORG: Your InfluxDB Cloud organization name.

For that, edit the following command with your own details:


For example, in my case, the command looks as follows:

export INFLUX_TOKEN=v_od_mG--9_srf_OnaaODihPDX34suToXXXXXXXXXXP7XEH47v6x

Then, run it on your Raspberry Pi.

Now, restart Telegraf with the following command:

sudo systemctl reload telegraf.service

Starting Telegraf

Start Telegraf as a service. For the exact command, you need to go to your InfluxDB interface, and then Data/Load Data > Telegraf. Click on the rpi Setup Instructions. Copy the command to start Telegraf.

Telegraf setup instructions

Run that command to start Telegraf. You should get something similar to the next image in your Terminal window.

Run Telegraf Raspberry Pi

At the moment, Telegraf should be collecting data from the Raspberry Pi and sending it to the corresponding bucket on InfluxDB.

Raspberry Pi System Dashboard

Now you can monitor your Raspberry Pi system on a Dashboard in InfluxDB. In your InfluxDB user interface, go to Boards/Dashboards (left sidebar) and click on the Raspberry Pi SystemA collection of useful visualizations for monitoring your system stats”.

Raspberry Pi System Monitoring Template Dashboard

You’ll get access to the Raspberry Pi System Dashboard. You can check useful information like the CPU and GPU temperatures, total memory, memory usage, and much more.

If you don’t see any data on the dashboard, make sure you select the right bucket rasp-pi and the linux_host is raspberrypi.

Congratulations! You set up an InfluxDB Telegraf to monitor your Raspberry Pi system.

Wrapping Up

In this quick guide, we’ve shown you how to use InfluxDB Telegraf to collect useful data from your Raspberry Pi and display it on a dashboard. You can monitor CPU usage, memory usage, disk usage, system load, CPU and GPU temperatures, and other useful data.

We hope you find this tutorial useful. We have other InfluxDB tutorials you may like:

Thanks for reading.

Build Web Server projects with the ESP32 and ESP8266 boards to control outputs and monitor sensors remotely. Learn HTML, CSS, JavaScript and client-server communication protocols DOWNLOAD »

Build Web Server projects with the ESP32 and ESP8266 boards to control outputs and monitor sensors remotely. Learn HTML, CSS, JavaScript and client-server communication protocols DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our newsletter!

13 thoughts on “Monitoring Your Raspberry Pi System using InfluxDB Telegraf”

  1. This is very interesting! I have a question though: is it possible to monitor the RP from a different device? I mean having the InfluxDB service running in a RP but the queries being executed from another PC? I am thinking about having a couple of RP running without any screen and being able to monitor their statuses from a laptop, for example. And being able to monitor both devices from one different computer.

    I assume it is possible, so I will try to find out reading the docs, but it would be an interesting project.

    • Hi.
      You can access InfluxDB dashboard from any device on the same network as the Raspberry Pi.
      I hope this answers your questions.

  2. “No Results” for all the metrics. Yes, originally, I had the bucket set to the name which I called it, but, then linux_host was empty. Then, I saw the last sentence before the “Rapping Up” Section. So, I set the bucket to “rasp-pi” and the linux_host is raspberrypi. No difference. Still “No Results” text displayed for all the metrics. And, I’ve rebooted, as well. Still no output.

    • I got this to work after much fiddling around:
      1. I uninstalled and reinstalled influxdb, (not sure these actions where absolutely necessary)
      2. To install influxDB, I used the link in from this article “Install InfluxDB 2 on Raspberry Pi”.
      3. During the Installation of InfluxDB, when creating the initial user, “Setup Initial User” Section, make sure you name the bucket “Raspberry-Pi”. If not, this I believe is what caused the problems I had later. I named my bucket “data-bucket”

      I believe the “Raspberry Pi Template” is expecting the bucket name to be “Raspberry-Pi”.

      In this article, in the “Getting an InfluxDB Token” it states, “Give a description to the API Token (for example Raspberry-Pi)”, I used the bucket name “data-bucket” from when I setup the Initial User. I believe the “Generate API Token” process uses the “Description” field when creating the API Token or something.

      Maybe there is an Influx Environment Variable that can be set for Telegraf to use for the Bucket Name. Therefore, overriding the expected bucket name of “Raspberry-Pi”

      • Hi.
        Thanks for sharing your experience with us.
        I’m not sure if that’s what caused the issue. I need to try with another token name and check what happens.

  3. Typing in :
    telegraf –config
    starts a second instance of telegraf that send raspberry pi data to influxdb.

    While that works fine, it only sends data while that command is running. If you do a to get back to the command line that kills the second instance of telegraf and data about the pi stops getting sent to influxdb.

    Do you have any hints about how to add raspberry pi monitoring to always run without needing a command line open? Possibly some changes to /etc/telegraf/telegraf.conf?


    • Solved it and posted as as response to a question on the RNT Facebook page).

      Here’s what I wrote :

      Out of the box, Telegraf starts automatically as a daemon with its default telegraf.service systemd script. It looks for a configuration file called telegraf.conf in /etc/telegraf/ to run. The default telegraf.conf file basically does nothing so just overwrite it.

      Create a new telegraf.conf by saving your script from the UI :
      Load Data -> TELEGRAF tab -> edit -> DOWNLOAD CONFIG

      Note that the telegraf.conf file gets the values for $INFLUX_HOST, $INFLUX_TOKEN and $INFLUX_ORG from /etc/defaults/telegraf. So you need to have the correct values there. Fill it in something like this :

      INFLUX_TOKEN=” ”
      INFLUX_ORG=” ”

      or just edit them directly into your config file (Useful if you plan to run multiple instances of telegraf daemons).



Leave a Comment

Download Our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.