Skip to content

openHAB: timestamp from last Item update

If openHAB has a Persistence service configured, the time of the last Item update (and a couple other times) is available in Rules. This makes it quite handy to check if a certain item hasn't been updated in a long time. As example I have the Tankerkoenig Binding installed, and this data is persisted in InfluxDB. This way I can see historic gas prices in Grafana.

When the Telegram Bot answers the "/tanken" question, it appends the timestamp of the last gas prices update.

 

Continue reading "openHAB: timestamp from last Item update"

Grafana: select host for a dashboard

InfluxDB is running on a Raspberry Pi in my home network (with separate attached disk), and I installed a Grafana on top of it, to visualize crucial data.

In Grafana it is possible to define a variable for a dashboard and this variable can query the data source and use the returned list of values. Let's say the variable is $host, then the data query can use:

WHERE host =~ /^$host$/

and limit the current dashboard to the selected host. Also the variable will provide a select field at the top of the dashboard, which allows selecting the system one wants to see:

Now usually - according to the documentation - a "SHOW TAG VALUES" in the data source should be sufficient However as it is, this did not work for me, and the query came back empty:

> show tag values from system with key = host

Looks like I'm not the only one with this problem.

 

Luckily there is a way around with another query:

select distinct("host") from (select "host","load1" from system)

The result:

> select distinct("host") from (select "host","load1" from system)
name: system
time distinct
---- --------
0    host1
0    host2
0    host3
0    host4
0    host5
0    host6

Grafana ignores the "time" column and uses the second column for the host list. Voila.

Monitor additional details in Telegraf with the "Exec" input filter

After installing Telegraf and hooking up everything into InfluxDB, I was missing the status of my backups. Every system here creates encrypted backups every night, and stores them on a central NAS, and off-site. But I want to know statistics about the backups, and see if something is not working.

I'm using Restic for the backups (will blog about this another time). However Telegraf does not support Restic directly, I need a few workarounds. This blog post however is not directly about monitoring the backups, but about how to write your own plugin for Telegraf.

 

Continue reading "Monitor additional details in Telegraf with the "Exec" input filter"

Install Telegraf using Ansible

I have an InfluxDB up and running in my network, and decided to monitor all (well, all possible - the QNAP seems to be a problem) devices. That's quite easy to do by installing Telegraf as a server agent, and add some configuration. Everything is deployed using Ansible, so I can re-use the same Playbook for many devices.

 

Continue reading "Install Telegraf using Ansible"

Add InfluxDB settings in Telegraf using Ansible: [WARNING]: The value [...] (type list) in a string field was converted to "[...]" (type string)

I'm in the process of updating my entire home setup, and integrate everything properly. Part of this process is to automate everything, and use Ansible Playbooks to deploy devices and configurations.

Today: install Telegraf and send data to InfluxDB

Along the way something broke, and Ansible doesn't really like me anymore. But let's start at the beginning.

In the Telegraf configuration in "/etc/telegraf/telegraf.conf" one can specify output plugins. One of them (probably the most used one) is "InfluxDB". The InfluxDB instance(s) are specified as a [...] list. In Ansible I somehow need to have this list as a string, and write it into the configuration file. This happens:

TASK [Update telegraf.conf InfluxDB settings] ***************************************************
changed: [localhost] => (item={'section': '[outputs.influxdb]', 'option': 'urls', 'value': ['http://192.168.xxx.xxx:8086'], 'state': 'present'})
[WARNING]: The value ['http://192.168.xxx.xxx:8086'] (type list) in a string field was converted to "['http://192.168.xxx.xxx:8086']" (type string). If this does not look like what you expect, quote the entire value to ensure it does not change.

Looks nasty ...

 

Continue reading "Add InfluxDB settings in Telegraf using Ansible: [WARNING]: The value [...] (type list) in a string field was converted to "[...]" (type string)"

Move InfluxDB data directory to a SDcard

For my openHAB system I installed InfluxDB (on a separate) Raspberry Pi. The Pi has a 32 GB SDcard, but that is not enough for storing all the data, and that Pi has additional work to do as well. For that reason I also attached a 1 TB disk to the Pi, and mounted it on /data. Now all I have to do is move the InfluxDB data directory to /data.

 

Continue reading "Move InfluxDB data directory to a SDcard"