Grafana: Docker - visualize data and define alarms

Diese Seite gibt es auch in Deutsch

Grafana is a web application for visualizing data. With Grafana you can create nice charts or define alarms in a few minutes.

Docker Basics

Docker allows applications to be launched by command in a so-called container.
A container is an isolated environment independent of the operating system (OS):
When a container is first launched, Docker independently loads all the necessary sources
from the internet.
Docker can be installed on Windows, macOS or an Linux Distribution

Requirements

As a prerequisite for Grafana, a data source is needed, preferably a "Time series database", i.e. a database optimized for time data. An example of such a "Time series database" is InfluxDB, see: Influx DB - Time series database.

In order to be able to display data in Grafana, these must of course somehow end up in the database, for example via ioBroker, see: ioBroker Install - Docker or HomeAssistant, see Home-Assistant Docker Conbee 2 and Zigbee2MQTT / deCONZ

Grafana

As a prerequisite I use my own network, if this is already available from ioBroker, the following command is obsolete.

docker network create smart-home

For the actual start of Grafana, I used the following command.

mkdir -p /docker
mkdir -p /docker/grafana
docker run -d \
-p 3000:3000  \
--network=smart-home \
--restart=always --name=grafana \
-v /docker/grafana:/var/lib/grafana grafana/grafana

After the first start "admin" is used as username and the password "admin".

Data source

As data source I use a previously created Influx container, see: Influx DB - Time series database

Information about the connection of an InfluxDB version 2 will follow shortly.

Integrating the ioBroker values of the Influx-DB and creating diagrams (charts)

Details about the ioBroker setup, see: ioBroker Installieren - Docker

Panel with 2 different units

Swap home dashboard

To use any dashboard as a home page, the first thing to do is to bookmark it and then select it in the settings.

Grafana image renderer Docker

To be able to attach images for notification, Docker requires its own image renderer container, this can be started as follows:

docker run -d \
--name=renderer \
--restart=always \
-p=3001:8081 \
grafana/grafana-image-renderer

To make the existing Grafana container talk to the image renderer, I had to adjust the container accordingly:

The address 192.168.1.5 is the IP address of the host, this must be adapted accordingly:

docker stop grafana
docker rm grafana

docker run -d \
-p 3000:3000  \
--network=smart-home \
-e "GF_RENDERING_SERVER_URL=http://192.168.1.5:3001/render" \
-e "GF_RENDERING_CALLBACK_URL=http://192.168.1.5:3000/" \
-e "GF_SERVER_DOMAIN=192.168.1.5" \
--restart=always \
--name=grafana \
-v /docker/grafana:/var/lib/grafana grafana/grafana

InfluxDB Error: unsupported mean iterator type: *query.booleanInterruptIterator

One little thing was not quite self-explanatory for me at the beginning. When creating a chart with true/false values, "Select" must be changed to "last()", otherwise the following error is thrown: unsupported mean iterator type: *query.booleanInterruptIterator

Docker: Install plugins

Plugins can be installed via the Grafana CLI:

grafana-cli plugins install PluginName

When using the Docker container, we need to connect to the container beforehand using "docker exec":

bernhard@sox:~$ docker exec -it grafana /bin/bash
bash-5.0$ grafana-cli plugins install natel-discrete-panel
installing natel-discrete-panel @ 0.1.1
from: https://grafana.com/api/plugins/natel-discrete-panel/versions/0.1.1/download
into: /var/lib/grafana/plugins

Conclusion

At my first attempt to start Grafana, I was very surprised how fast, easy and self-explanatory data can be visualized with it. A prerequisite for using Grafana is of course a database, which is also done in a few minutes with Docker and InfluxDB. Then there is the actual data for the database, which comes, as already described, from ioBroker and Conbee.

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-05-09 from Bernhard 🔔


Top articles in this section


Nextcloud Server Docker | Setup + https: Let's Encrypt [ssl]
To synchronize contacts, appointments, and photos of my NAS, I tested Nextcloud and thus turned my back on other cloud providers for my private data. Thanks to Docker, the installation is easier and more flexible than ever, allowing Nextcloud to run on almost any hardware.

Conbee 2: Phoscon deCONZ - Docker Startup | Review
With the small USB stick Conbee2 I extended my NAS with a Zigbee gateway. Conbee2 can be installed on Raspbian, Ubuntu, Docker or Windows.

Home Assistant Docker Conbee 2 and Zigbee2MQTT / deCONZ
Thanks to numerous integration options,Home Assistant is a simple platform for controlling a wide range of smart home devices. Compared to ioBroker, I found it much easier to get started with Home Assistant. While for ioBroker I was still searching for which frontend I could use for my dashboards, with Home-Assistant I had a ready-made system out of the box. Home Assistant's Lovelance dashboards can be easily clicked together in the GUI and adapted for special customizations in the code editor...

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details