InfluxDB+Grafana persistence and graphing

The persistence for InfluxDB does impose some limitations: you can’t use the tags and the multiple values and different retention policies in InfluxDB. For example, you could have a measurement “Temperature” and the tags “Inside” and “Outside”. Or maybe you want some measurements saved forever and others for much less time. You can use continuous queries to down sample, but it doesn’t cover every case. Also, you can have a measurement “SensorValues” with values such as Temperature and Humidity all within that measurement. Fortunately there is quite an easy workaround with the HTTP post request. I’ve put a sample below for anyone who is interested. If you’ve used the authentication above, you’ll need to add it to the http val. And of course modify it to your liking.

The InfluxDB write documentation is here

I use a timer to not bog down the rules when the post request is running.

val String INFLUXDB_WRITE = "http://192.168.86.212:8086/write?db=openhab_db&rp=autogen"
var Timer influxWriteTimer = null

rule "End Peak"
when
    Time cron "0 0 20 ? * MON-FRI *"
then
    if (influxWriteTimer === null) {
        influxWriteTimer = createTimer(now, [|
	    sendHttpPostRequest(INFLUXDB_WRITE, "application/json", "KWHPeak value=" + KWHPeak.state.toString, 3000) // 
            influxWriteTimer = null
        ])
    } else {
        logWarn("eagle", "Influx write timer is still running, not creating another")
    }
en
1 Like

I want to implement a “Direct Link Rendered Image” into my Habpanel.

Problem is, that the background is black from the dark theme or white from the light theme.

In the thread of the matrix theme I saw that it should be possible to create a css file, which I have to implement into the index.html file under directly below the title tag.
I did this, but without success.

Is there somebody who solved this?

In Installed influxdb and grafana according to the describtion above, version 1.0.2. was installed (using an Pi 3+).
But i cannot go to the command line interface?

When I run influx, the answer is command not found.
I can start somethin running influxd. Then i get this:

[14:59:28] openhabian@openHABianPi:~$ influxd

8888888 .d888 888 8888888b. 888888b.
888 d88P" 888 888 "Y88b 888 "88b
888 888 888 888 888 888 .88P
888 88888b. 888888 888 888 888 888 888 888 888 8888888K.
888 888 "88b 888 888 888 888 Y8bd8P’ 888 888 888 "Y88b
888 888 888 888 888 888 888 X88K 888 888 888 888
888 888 888 888 888 Y88b 888 .d8"“8b. 888 .d88P 888 d88P
8888888 888 888 888 888 “Y88888 888 888 8888888P” 8888888P”

[run] 2019/02/10 14:59:29 InfluxDB starting, version 1.0.2, branch unknown, commit unknown
[run] 2019/02/10 14:59:29 Go version go1.7.3, GOMAXPROCS set to 4
[run] 2019/02/10 14:59:30 Using configuration at: /etc/influxdb/influxdb.conf
run: open server: listen: listen tcp :8088: bind: address already in use

but why cant i go to the cli?

influxd is the daemon (and already started… bind: address already in use)
if there is an influxd, there also should be an influx (which is the connection to the database command line)

Maybe you have to use

sudo influx

instead.

I would try this. I recently installed influxdb and got only the server and not the client on Ubuntu 18.04 server. Perhaps they have separated the server and the client in the latest package.

sudo apt-get install influxdb-client

finding the influx command was what hung me up trying to do this tutorial. Eventually I found info telling me to point my web browser at the web interface which can be found at
localhost:8083
after install
the web interface allows the creation of databases, users and permissions
hope it helps

Port 8083 for admin can work, but you need to enable it first in the influxdb.conf file in the admin section as the default is disabled. Also, it says that the interface is deprecated and will be removed in a future release.

Hope this is the correct location for my two questions …

I measure few temperatures, store the values every 5 minutes in an influxdb.
Now, the graph for 1 day (or less) view has “steps” because of less values.
But is there an option that Grafana interpolate (create a curve betwen the point) and the graph looks “smoother” ?
(Otherwise I have to save every minute the temperatues into the influxdb …)

And in Grafana under “Legend” I activate “Show” and “As table”:
But this will only show (the first) three temperature sensores I added (in the graph there are six shown, thats correct). See picture
When activating additionally “To the right”, than all six values are shown on the right part from the screen (but than the graph is to much shrinked). Is this a limitation, a Bug or a mistake on my side?

For the first question, select “connected” for the null value in the Display tab in Grafana. There’s a picture here.

1 Like

OK, for my second question I found out:
When moving over on the right part, a scroll line appear!
Without move-over there is NO hint that there are more lines!

But in my case it would bether to see all 6 lines directly, is there an option?

Hello All, i’m in need of a tiny bit of help…
I’m sure the issue will be obvious to someone, i can’t seem to put my finger on it.

I confess i ventured into installing InfluxDB and Grafana from the openhabian-config>optional components installation ( i thought: “it’s been 2 years ever since Thomas Dietrich wrote this tutorial, let’s be brave!” - btw the tutorial is definitely still relevant, so TY).
The automated setup process sets up most of the things for you, basically all there is left is to install the addon in paperui and schedule a persistence job.

I now have the follwoing situation:
Grafana says it has no issues in connecting to opehab_db from influx as datasource
image
Influx receives data from OH, as per the scheduled job, (with precision rfc3339)

…But when i go creating a graph in my first dashboard


i don’t get any result, except for a “no data points” written in the middle of the graph.

I’m sure i missed something silly (as usual for any first timer the amount of info can be overwhelming).
any pointers?
Thanks!!

EDIT: do i need to write SELECT * FROM … so influxdb CLI commands in the grafana query for it to work??
EDIT 2: i’ve tried logging into influx’s CLI with grafana’s credentials and reading the measurements, but got this error:


so i guess the automated process doesn’t do
image

EDIT for anybody who might face the same issue
if you install Grafana and InfluxDB from the automated procedure in the openhabian-config, you need to log into influx’s CLI as ‘admin’ with the ‘SuperSecretPassword123+’ you’ve set up during the process, and do the 2 GRANT commands above. otherwise it’s not going ot work XD

took me hours (-.-) XD

2 Likes

May i ask how did you achieve this?

I’m guyessing you’re feeding system stats to influxdb from somwhere…?

I’m not sure if I understand the question, but I basically just store values from Systeminfo Binding via influxdb persistance.

1 Like

XD that’s it!
didnt’ explore systeminfo yet, was checking nmon from time to time.
now with grafana makes a lot more sense.
ty!

Hi there!
How can i update Grafana? I’m on 5.1.4 - according to the grafana homepage there’s 6.0 available.
i’m trying to update because (maybe?) 6.0 solves my problem with scrollbars on habpanel :slight_smile:

cheers
Peter

Assuming you are using Debian or Ubuntu, the easiest method to upgrade Grafana is to use apt according to the instructions here: http://docs.grafana.org/installation/debian/

i’m on openhabian (raspberry),

sudo apt-get install grafana

is not working there :frowning:

You followed all of the instructions on the link to add the key? Or just tried the install? You need to follow all of the instructions:

APT Repository

Create a file /etc/apt/sources.list.d/grafana.list and add the following to it.

deb https://packages.grafana.com/oss/deb stable main

There is a separate repository if you want beta releases.

deb https://packages.grafana.com/oss/deb beta main

Use the above line even if you are on Ubuntu or another Debian version. Then add our gpg key. This allows you to install signed packages.

curl https://packages.grafana.com/gpg.key | sudo apt-key add -

Update your Apt repositories and install Grafana

sudo apt-get update
sudo apt-get install grafana

Hi,

does anyone have an idea why transparency doesn’t work, if a graph is used in HABpanel using an iframe? I don’t think that it is an issue of grafana since transparency works without problems, if the frame is opened directly. Is there any additional HABpanel or CSS setting necessary to make this work in HABpanel?

Screenshot:
grafana_transparency

relevant html snippet:

<div class="section">
  <div class="bigDash">
    <div class="top">
      <div class="icon on"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/material-icons.svg#thermometer"></use></svg></div>
      <div class="value">
        <div class="main">{{(itemValue('Thermostat_Temperatur').split(' ')[0] | number:0)}}</div>
        <div class="decimals">,{{(itemValue('Thermostat_Temperatur').split(' ')[0] | number:1).split(',')[1]}}</div>
        <div class="sub">&#176C</div>
      </div>
    </div>
    <div class="bottom">
      <div class="icon off"><svg viewBox="0 0 48 48"><use xlink:href="/static/matrix-theme/material-icons.svg#trending-neutral"></use></svg></div>
      <div class="value">{{itemValue('Thermostat_Setpoint')}}</div>
    </div>
    <div class="graph">
      <iframe src="https://<grafana-url>:3000/d-solo/000000003/habpanel?panelId=1&orgId=1&refresh=30s&tab=general&from=now-24h&to=now" width="90%" height="150" frameborder="0"></iframe>
      <div class="legend">Letzte 24h</div>
    </div>
  </div>
</div>

CSS: https://github.com/boehan/openhab-habpanel-theme-matrix/blob/master/matrix-theme.css

Any input greatly appriciated!
Hans

Hi,

I write here because after searching and searching I have not found a solution to my problem. I followed the whole tutorial and I was able to install influxdb and grafana perfectly, I even have several graphs working on my sitemap with influxdb. My problem comes with grafana. I could only enter when I installed it and after that I could not do it anymore. I have reinstalled it several times without success. It appears in my openhab web panel but when I click it it does not connect me. The truth is that I have searched and tried many things before writing here. In the log I do not see any error regarding grafana. I do not know what else to do. It may be silly and I do not see it but I have run out of ideas.
My setup is:

Hardware: Raspberry PI 3B
OS: openHABian v1.4.1
Java Runtime Environment: openjdk version “1.8.0_152”
OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8 .0_152-b76)
OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, m ixed mode, Evaluation)

Grafana’s version is the last.


If anyone could advise me, I would appreciate it. Thank you so much for everything. Regards:)