InfluxDB+Grafana persistence and graphing

This is a bit special and openHAB does not support this. It’s more a SQL job, I think. So maybe another forum is a better (i.e. there are more people to help with this problem)

I’m using a simple bash script to import daily measurements from my photovoltaic system, but I do it to store in MariaDB and I don’t use this measurements in openHAB or Grafana…

I don’t think anyone has posted an example of this because it’s usually handled outside of openHAB. As Udo indicates, you’d write a script that inserts the data into InfluxDB instead of relying on openHAB to do it.

To clarify a bit, the openHAB persistence services are not intended for general purpose database access, and do not allow arbitrary timestamping.
For openHAB, persistence is about recording (and later reading) Item states only, a snapshot of the state “now”, if you will.

You can send directly to InfluxDB using the sendHttpPostRequest and bypass the persistence. Then you can send anything you want including the timestamp. Example here of a different retention policy.

hi,
i installed via openhabian and changed /etc/grafana/grafana.ini according to the first post.
i can open the graph from a “not logged in” browser, but habpanel (frame with url = http://ip-address:3000/d-solo/3L-5BqzRk/openhab-dashboard?tab=query&orgId=1&from=now-48h&to=now&panelId=2) doesn’t show the graph:

ip-address refused the connection

as i can see the graph in another browser where i’m not logged in i think the error is with the habpanel frame, right?

edit: oh, and another thing:

To render a panel image, you must install the Grafana Image Renderer plugin. Please contact your Grafana administrator to install the plugin.

iirc the image renderer was installed on a previous openhabian setup, wasn’t it?

1 Like

Grafana deprecated that plugin quite some time ago. Now there is a separate service. See Grafana Image Renderer for a way to install and use the new separate service using Docker.

ok, i didn’t know this. thanks for the link!
i tried the simple approach, but

Error: ✗ plugin is not supported on your architecture and OS.

i have not tried the manual installation but at the moment i don’t necessarily need the image renderer.

apparently this i needed in grafana.ini so habpanel can embed graphs:
allow_embedding = true

maybe @ThomDietrich could add it in the first post?

1 Like

I did this and it looked ok installing influxdb 1.6.4-1
Unfortunately running influx does not work.
There is no such file neither in /usr/bin nor somewhere else.

Platform information:
    Hardware: RPi 4 8 GB and 32 GB micro SD + zwave: Aeotec Z-Stick Gen5 (ZW090) - UZB
    OS: Raspian which comes with openhabian 1.6a
    Java Runtime Environment: Zulu 8 (standard openhabian)
    openHAB version: 2.5.9-1 (standard openhabian)

Someone with the same issue?

EDIT: Never mind.
Found the solution in this thread:

sudo apt-get install influxdb-client

:blush:

1 Like

Hej folks,

I have recently started to set up my openHAB and get my first experiences. Even if it is certainly a question for beginners, but I hope it is properly placed here.
I would like to show the current voltage value and the current power in a Grafana diagram. For this purpose I have installed the packages for InfluxDB and Grafana via the openhabian-config. Furthermore I installed the package for the InfluxDB-client and the binding. Everything as described in the tutorial. But I have problems to implement the Influx database in Grafana. Can you tell me exactly what I have to enter in the mask? Unfortunately the picture of the tutorial is a bit old. The mask has changed since then.

Thanks for your help. I am grateful for any support.

You should enter the the credentials for the user “grafana-user” there. You created this user with openhabian-config. The user has only read access to the database.
My config looks like this. I think normally the name of the database is “openhab”:

The first time I also had some problems to connect to the database. You should try a different browser, which worked for me.

Did you already set up the persistence in openhab?

Total newbie to Grafana (installed it yesterday) so I’m trying to take my baby steps in utilizing it. As I understand it, it’s pretty straight forward to create a graph for measurements like current/instant power load(W or kW) or temperature (C or F), but what about an ever increasing value for power consumption (kWh)? Let’s say, I take a daily measurement, is it possible to create a bar chart for daily, weekly or similar power consumption - even if I don’t have the calculated daily consumption as in the example below?

You dont have to calculate anything. Grafana will do it for you… All you have to do, is to define which periode you want to see. (ie day, week, month, year etc).

I’ve followed the tutorial above and managed to insert the sine wave data. I’m now having problems connecting influxdb to openhab. I added influxdb and grafana via openhabian-config

My /etc/openhab/services/influxdb.cfg has the following

url=http://10.1.1.78:8086
user=myuser
password=1234
db=openhab
retentionPolicy=autogen

I’m getting the following error in /var/log/openhab/events.log

2021-02-08 20:03:00.268 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ConnectException: Failed to connect to /10.1.1.78:8086

If i try and connect to influxdb via CLI using the IP address of my host i get the following error:

sudo influx -username myuser -password 1234 -host 10.1.1.78
Failed to connect to http://10.1.1.78:8086: Get http://10.1.1.78:8086/ping: dial tcp 10.1.1.78:8086: connect: connection refused
Please check your connection settings and ensure 'influxd' is running.

If i try and connect to influxdb via CLI using localhost i can log in, suggesting that I,m using the correct username and pswd:

sudo influx -username myuser -password 1234 -host localhost
Connected to http://localhost:8086 version 1.8.4
InfluxDB shell version: 1.8.4
>

Changing the url in influxdb.cfg to localhost:

url=http://localhost:8086
user=myuser
password=1234
db=openhab
retentionPolicy=autogen

still produces an error

2021-02-08 20:32:00.678 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost
org.influxdb.InfluxDBIOException: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8086

Openhabian 3.0 on RPi4.

Update: I notice in the original OP there is special mention of RPi install here. :blush: I’ve removed influxdb and grafana and will try that process.

I´m also having trouble with openhab 3.x and a fresh grafana install via openhabian.

Frontail log is telling me

[ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost

Grafana DB check is all green when saving.

I have the same Problems as @Rar9. It seems that influxdb and grafana-server dont start at boot.
After booting grafana isnt reachable via openhabianip:3000 until I run sudo systemctl start grafana-server.service

I also have the same error as @Rar9 until I start influxdb manually via sudo systemctl start influxdb.service

I also tried sudo systemctl enable grafana-server.service and sudo systemctl enable influxdb.service but after a reboot it seems neither influxdb nor grafana is startet.

This sounds more like a openHABian issue than a Grafana/InfluxDB issue.

I think you might be better off creating a new thread in this forum.

And maybe check the system logs to see if there are any hints about your issue.

Already did that here: Influxdb and grafana dont start at boot if anybody has the same problems. Still searching for a solution

Hello

I am already using grafana+influxdb to store & plot some data I receive in MQTT. However, I’m persisting data on the fly.
I would like to store data I am retrieving the previous day which is valid for the next day.

More details: I am doing HTTP request which returns price of energy for the next day. Hour by hour.
I would like to store this data in influxdb and show it in grafana.

Can you give me some hint on how to perform this?
Below is an example of the data:

[{"start_date":"2021-04-15T00:00:00+02:00","end_date":"2021-04-16T00:00:00+02:00","updated_date":"2021-04-14T13:07:28+02:00","values":[{"start_date":"2021-04-15T00:00:00+02:00","end_date":"2021-04-15T01:00:00+02:00","value":13963.5,"price":68.27},{"start_date":"2021-04-15T01:00:00+02:00","end_date":"2021-04-15T02:00:00+02:00","value":13738.5,"price":63.38},{"start_date":"2021-04-15T02:00:00+02:00","end_date":"2021-04-15T03:00:00+02:00","value":14532.8,"price":64.78},{"start_date":"2021-04-15T03:00:00+02:00","end_date":"2021-04-15T04:00:00+02:00","value":13673.5,"price":59.71},{"start_date":"2021-04-15T04:00:00+02:00","end_date":"2021-04-15T05:00:00+02:00","value":12933.3,"price":61.16},{"start_date":"2021-04-15T05:00:00+02:00","end_date":"2021-04-15T06:00:00+02:00","value":13123.2,"price":65.81},{"start_date":"2021-04-15T06:00:00+02:00","end_date":"2021-04-15T07:00:00+02:00","value":12878.7,"price":82.9},{"start_date":"2021-04-15T07:00:00+02:00","end_date":"2021-04-15T08:00:00+02:00","value":13515.2,"price":105.05},{"start_date":"2021-04-15T08:00:00+02:00","end_date":"2021-04-15T09:00:00+02:00","value":13679.3,"price":118},{"start_date":"2021-04-15T09:00:00+02:00","end_date":"2021-04-15T10:00:00+02:00","value":16229.8,"price":99.8},{"start_date":"2021-04-15T10:00:00+02:00","end_date":"2021-04-15T11:00:00+02:00","value":18072.6,"price":82},{"start_date":"2021-04-15T11:00:00+02:00","end_date":"2021-04-15T12:00:00+02:00","value":18687.3,"price":75.16},{"start_date":"2021-04-15T12:00:00+02:00","end_date":"2021-04-15T13:00:00+02:00","value":18954.9,"price":70.67},{"start_date":"2021-04-15T13:00:00+02:00","end_date":"2021-04-15T14:00:00+02:00","value":17284.3,"price":69},{"start_date":"2021-04-15T14:00:00+02:00","end_date":"2021-04-15T15:00:00+02:00","value":16575.1,"price":63.72},{"start_date":"2021-04-15T15:00:00+02:00","end_date":"2021-04-15T16:00:00+02:00","value":15835.6,"price":60.55},{"start_date":"2021-04-15T16:00:00+02:00","end_date":"2021-04-15T17:00:00+02:00","value":15132.9,"price":57.77},{"start_date":"2021-04-15T17:00:00+02:00","end_date":"2021-04-15T18:00:00+02:00","value":14813.8,"price":61.18},{"start_date":"2021-04-15T18:00:00+02:00","end_date":"2021-04-15T19:00:00+02:00","value":14891.6,"price":70.14},{"start_date":"2021-04-15T19:00:00+02:00","end_date":"2021-04-15T20:00:00+02:00","value":13748.8,"price":82.89},{"start_date":"2021-04-15T20:00:00+02:00","end_date":"2021-04-15T21:00:00+02:00","value":13506.9,"price":82.9},{"start_date":"2021-04-15T21:00:00+02:00","end_date":"2021-04-15T22:00:00+02:00","value":14100.4,"price":78},{"start_date":"2021-04-15T22:00:00+02:00","end_date":"2021-04-15T23:00:00+02:00","value":14465.2,"price":72.25},{"start_date":"2021-04-15T23:00:00+02:00","end_date":"2021-04-16T00:00:00+02:00","value":15946.5,"price":68.58}]}]

What is stopping you? You can’t store data for the future in persistence. But it’s just data, you know if you look at “yesterday’s” data it is about tomorrow.

Previous dscussion -

1 Like

What panel did you use to have a graph behind the gauge?
I’am looking for this option, but cant find it.