Thursday, March 28th, 2024
Latest updates
Grafana dashboard example

How to install Grafana+InfluxDB on the Raspberry Pi

InfluxDB is an easy to use open-source time series database developed by InfluxData. It is written in Go and optimized for fast, high-availability storage and retrieval of time series data in fields such as operations monitoring, application metrics, Internet of Things sensor data, and real-time analytics. It also has support for processing data from Graphite. A time series database have the series records always associated with a timestamp. You can provide the timestamp with the measurement data or the Influx database will generate it itself.

Grafana is an open source, feature rich metrics dashboard and graph editor for Graphite, Elasticsearch, OpenTSDB, Prometheus and InfluxDB.

Combining Influxdb+Grafana makes an easy to use database and a very flexible and good-looking dashboard for your next Raspberry Pi datalogger project.

TCP port 8086 is used for client-server communication over InfluxDB’s HTTP API.
TCP port 8088 is used for the RPC service for backup and restore.
In addition to the ports above, InfluxDB also offers multiple plugins that may require custom ports. All port mappings can be modified through the configuration file, which is located at /etc/influxdb/influxdb.conf for default installations.

InfluxDB installation instructions on Raspberry Pi:

#1. Add the InfluxData repository configuration by using the following commands:

Note: After hitting enter on some commands, a new prompt appears and nothing else is displayed. In the Command Line Interface, CLI, this means the statement was executed and there were no errors to display. There will always be an error displayed if something went wrong. No news is good news!
Copy the following commands to your CLI and hit enter. Your installed version on Raspian will be evaluated and the correct version will be added to your /etc/apt/sources.list.d.

wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/os-release
test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
#2.Install InfluxDB from the repository prevuously added in /etc/apt/sources.list.d/influxdb.list
sudo apt-get update && sudo apt-get install influxdb
#3. Start the InfluxDB service:
sudo service influxdb start
InfluxDB configuration

The system has internal defaults for every configuration file setting. View the default configuration settings with the influxd config command. Most of the settings in the local configuration file (/etc/influxdb/influxdb.conf) are commented out. All commented-out settings will be determined by the internal defaults. Any uncommented settings in the local configuration file override the internal defaults. Note that the local configuration file does not need to include every configuration setting. There are two ways to launch InfluxDB with your configuration file:
Point the process to the correct configuration file by using the -config option:

influxd -config /etc/influxdb/influxdb.conf

Set the environment variable INFLUXDB_CONFIG_PATH to the path of your configuration file and start the process.
For example:

echo $INFLUXDB_CONFIG_PATH /etc/influxdb/influxdb.conf

influxd

InfluxDB first checks for the -config option and then for the environment variable. See the Configuration documentation for more information.

To configure the InfluxDB first open the config file in the text editor nano:

sudo nano /etc/influxdb/influxdb.conf

I did the following configuration in the /etc/influxdb/influxdb.conf file:

Configure the HTTP endpoint to get data in and out of InfluxDB:
(Edit the following rows by removing the “#” tag.)

InfluxDB http configuration file edit

Restart InfluxDB after modifying the file: ​

sudo service influxdb restart
Test the InfluxDB installation

Open the Raspberry web browser and type:

localhost:8086
Instead of writing “localhost” in the address field you could enter the real IP address of your raspberry Pi: Example: 192.168.1.101:8086. If you don’t know the IP address you, can easily find if by using the bash command

sudo hostname -I

If it works,you should see the following html page:

404 page not found
Yes, that’s right, on port 8086 you will see a 404 page. The browser will complain: “This site could not be reached” if the database is not found.

You could also try to run the Influxdb command shell by typing

influx

in the terminal.
When you see this response you know that it is working:
influxdb shell

Type

exit

to get out of the Influx shell.

Before you dive into InfluxDB, it’s good to get acquainted with some of the key concepts of the database. This document provides a gentle introduction to those concepts and common InfluxDB terminology. With InfluxDB installed, you’re ready to start doing some awesome things. Getting started guide here.

Grafana installation instructions on RaspberryPi:

Check commands in Grafana for ARM, in case there is a new version available.

#1. Update your apt source

For Raspberry pi 1, and Raspberry Pi Zero W, use:

wget https://dl.grafana.com/oss/release/grafana-rpi_6.2.2_armhf.deb 
sudo dpkg -i grafana-rpi_6.2.2_armhf.deb

For Raspberry pi 2, and Raspberry Pi 3, 3B, 3B+, use:

wget https://dl.grafana.com/oss/release/grafana_6.2.2_armhf.deb 
sudo dpkg -i grafana_6.2.2_armhf.deb
#2. Update available packages and Install Grafana
sudo apt-get update
sudo apt-get install grafana
#3. Start the server (init.d service)

Start Grafana by running:

sudo service grafana-server start

This will start the grafana-server process as the grafana user, which was created during the package installation. The default HTTP port is 3000 and default user and group is admin.

To configure the Grafana server to start at boot time:

sudo update-rc.d grafana-server defaults
#4. Test the Grafana installation

Open the Raspberry Chromium web browser and type:

localhost:3000
You will then see the Grafana login page:
Grafana login html image

You made it!

You’ve sucessfully installed Influxdb and Grafana on your Raspberry Pi supercomputer. If you’re just starting out, we recommend taking a look at Grafana well made documentation for Basic Concept and Getting Started guides.
Other related useful information can be found here:
Using InfluxDB in Grafana
InfluxDb api client libraries for Python, C, Perl etc.

About Terje

Check Also

How to setup UART on the Raspberry Pi 3 GPIO

How to setup the UART on Raspberry Pi 3

Tips and tricks about configuring the UART on the Raspberry Pi 3 and Pi Zero W. The introduced bluetooth module makes this a little bit different.....

Datalogger example using Sense Hat, InfluxDB and Grafana

In this article we will make a simple datalogger application running on the Raspberry Pi. It is compatible with Raspberry Pi Zero W, Pi 2 and Pi 3.

50 Raspberry Pi Linux Bash commands you’ll actually use

So, what is Bash? The terminal (or ‘command-line’) on a computer allows a user a …

20 comments

  1. First command:

    curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -source /etc/os-release

    should be on two lines (2 commands):

    curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add –
    source /etc/os-release

  2. Good job, but InfluxDB performance is not good. I would recommend to you e.g. https://corlysis.com/

  3. I suggest you change the section about starting influx to set teh precision for date/time format using:
    influx -precision rfc3339

  4. In section #1 (see comment from Julian), execute the following command after those written by the author:

    test $VERSION_ID = “9” && echo “deb https://repos.influxdata.com/debian stretch stable” | sudo tee /etc/apt/sources.list.d/influxdb.list

    This adds the repos for Raspbian Stretch, the latest OS for Raspberry Pi.

  5. For Jessie 8.0

    curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add –

    lsb_release -a

    sudo apt install apt-transport-https
    echo “deb https://repos.influxdata.com/debian jessie stable” | sudo tee /etc/apt/sources.list.d/influxdb.list
    sudo apt update

  6. awesome thanks a load!

  7. Great guide! Everything works, all tests are fine, BUT I can’t start influx from prompt. I Only get:
    pi@raspberrypi:~ $ influx
    bash: influx: fant ikke kommando (=can’t find command)
    Any ideas why?

  8. Bradley D. Keister

    Hello,

    I need help. After putting the correct URL into influxdb.list and running the following:

    sudo apt-get update && sudo apt-get install influxdb

    I get

    E: Unable to locate package influxdb

    I was able to locate a tar file and put its contents into /etc, /var, /user. When I then type:

    influxd -config /etc/influxdb/influxdb.conf

    I get

    run: open server: open tsdb store: mkdir /var/lib/influxdb/data/_internal/_series: permission denied

    If I preface the command with sudo, it runs longer and hangs

    If I type

    sudo service influxdb start

    I get
    Failed to start influxdb.service: Unit influxdb.service failed to load: No such file or directory.

    Is there a longer tutorial about how to do this? I’m getting error messages at almost every step.

  9. I also needed the following to login into influx:

    sudo apt install influxdb-client

  10. Is there a chance to relocate the InfluxDB to a dedicated folder? I use a Raspberry PI with SD card and want to reduce the amount of read/write operations…

    • I have been thinking about this too.

      A dedicated folder on the SD card won’t help, because it is still on the SD card.

      A ramdisk (folder) would work but it will eat up your system memory fast. After all, you use a database to store (large) amounts of data. So using a ramdisk for an InfluxDB is a kind of a contradiction.

      There are t wo possible solutions:
      Attach an external storage (e.g. a SDD or mechanical HD) and configure InfluxDB to use it as the storage path or expand your Raspberry Pi that it runs from a SSD/HD (there are several extension kits that allow just that).

  11. Is it possible to have influxdb on a another computer, and still use the raspien (rpi3b+).
    And fetch or get the Temp data from rsp??.
    Is it possible and How ???

  12. Thank you for writing this tutorial.
    Still applicable to the latest version of influxdb (1.8.9) and grafana (8.1.5)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.