InfluxDB+Grafana persistence and graphing

Would be great if this new info could be added to the tutorial.Would save some frustrating hours especially for first time grafana users wondering why charts are not showing.Other than that the tutorial is perfect.

# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
allow_embedding = true
1 Like

Would be better to trigger @ThomDietrich as he wrote the tutorial :wink:

Hi all need some help debugging,

Starting Point - I am on ubuntu, OH 2.4, InfluxDB persistence service configured
InfluxDB Installation and Setup - installed, and I am able to view data with chronograph
Grafana Installation and Setup - never mind for now but installed
Connecting Grafana to InfluxDB - never mind for now but confgired
Connecting openHAB to InfluxDB - I have configured items
/etc/openhab2/services/influxdb.cfg :
/etc/openhab2/persitence/influxdb.persist :

but after all this, I cannot see an error or good logs…
and looking at chronograph I have no data coming in to the DB chosen for OH,
when I change let’s say IP for the Influx server I am getting a connection issue so I assume I am connected ,when I have no error

i am able to insert data with CLI …

Thanks

Thank you so much for that howto! Grafana looks pretty awesome.

Maybe anyone tried already to migrate their old data from rrd4j to influxdb by using the rest2influxdb script?

The import is not working as you can see:

:~/rest2influxdb$ ./rest2influxdb.sh Humidity_Kaum_HT

timestamps

item: Humidity_Kaum_HT
10y: 2009-09-24T19:41:15+02:00
1y: 2018-08-27T19:41:15+02:00
1m: 2019-08-26T19:41:15+02:00
1w: 2019-09-17T19:42:15+02:00
1d: 2019-09-23T19:42:15+02:00
8h: 2019-09-24T11:42:15+02:00
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 100 338 0 0 1838 0 --:–:-- --:–:-- --:–:-- 1836
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 100 338 0 0 7764 0 --:–:-- --:–:-- --:–:-- 7860
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 100 338 0 0 10411 0 --:–:-- --:–:-- --:–:-- 10903
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 100 338 0 0 10147 0 --:–:-- --:–:-- --:–:-- 10562
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 100 338 0 0 9843 0 --:–:-- --:–:-- --:–:-- 10242
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 338 100 338 0 0 10136 0 --:–:-- --:–:-- --:–:-- 10562

found values: 0

Warning: Couldn’t read data from file “Humidity_Kaum_HT-*”, this makes an
Warning: empty POST.
HTTP/1.1 204 No Content
Content-Type: application/json
Request-Id: 82324905-def2-11e9-83c2-b827eb4abb45
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.7.8
X-Request-Id: 82324905-def2-11e9-83c2-b827eb4abb45
Date: Tue, 24 Sep 2019 17:41:15 GMT

Sleep for 5 seconds to let InfluxDB process the data…

delete temporary files

The xml files that this script produces for the import step do have the following content:

{"error":{"message":"2009-09-24T10:27:25 02:00 is not in a valid format.","http-code":500,"exception":{"class":"java.lang.IllegalArgumentException","message":"2009-09-24T10:27:25 02:00 is not in a valid format.","localized-message":"2009-09-24T10:27:25 02:00 is not in a valid format.","cause":"java.time.format.DateTimeParseException"}}}{"error":{"message":"2018-08-27T10:27:25 02:00 is not in a valid format.","http-code":500,"exception":{"class":"java.lang.IllegalArgumentException","message":"2018-08-27T10:27:25 02:00 is not in a valid format.","localized-message":"2018-08-27T10:27:25 02:00 is not in a valid format.","cause":"java.time.format.DateTimeParseException"}}}{"error":{"message":"2019-08-26T10:27:25 02:00 is not in a valid format.","http-code":500,"exception":{"class":"java.lang.IllegalArgumentException","message":"2019-08-26T10:27:25 02:00 is not in a valid format.","localized-message":"2019-08-26T10:27:25 02:00 is not in a valid format.","cause":"java.time.format.DateTimeParseException"}}}



That means its pretty obvious that there is a problem related to timestamps?
The Data i would like to import is temperature data from the jeelink_lacrosse binding.

i am using openHAB 2.5.0~M3-1 (Milestone Build)
with influxdb 1.7.8 & grafana v6.3.6 installed through openhabian-config
The Script is from GitHub - CWempe/rest2influxdb in the latest master version

Would be really glad if somebody could assist me!

best regards and thanks in advance,
Walter

When trying to delete invalid data, this works as admin via:

DELETE FROM my_measurement WHERE time = 1469484042447000000

But when I try to delete via

DELETE FROM my_measurement WHERE value = 0

I receive the following error:

ERR: shard 178: fields not supported in WHERE clause during deletion

Any idea how I can delete several invalid measurements efficiently?

Thanks and best
MatzeMuc86

I made a new clean install of openHAB 2.5.0.M3 Milestone Build. Then I installed InfluxDB+Grafana through the openhabian Configuration Tool. All went fine but when I wanted to create the Database with

influx
CREATE DATABASE openhab_db

I get this error:

ERR: unable to parse authentication credentials
Warning: It is possible this error is due to not setting a database.
Please set a database with the command “use ”.

I don´t know what I have missed.
User:

[12:29:05] openhabian@openhab:~$ influx

Grafana website works.
I also tried the solution from chris669

OK, Reply to myself… After investigating through the forum, I’ve seen this post and now for those who encountered the same problem, beware, the script installing InfluxDB and Grafana doesn’t do all the job. DATABASE is not installed!
In my case, after a clean install, I had to proceed this way:
sudo chown -hR openhab:openhab /etc/openhab2
sudo chown openhab:openhabian /etc/openhab2/services/influxdb.cfg
influx -port 8086 -username myusername -password mypassword -host localhost
CREATE DATABASE openhab_db
CREATE USER myusername WITH PASSWORD ‘mypassword’ WITH ALL PRIVILEGES
CREATE USER openhab WITH PASSWORD ‘myopenhabpassword’
CREATE USER grafana WITH PASSWORD ‘mygrafanapassword’
GRANT ALL ON openhab_db TO openhab
GRANT READ ON openhab_db TO grafana

But it doesn´t work.

You could try https://github.com/CymaticLabs/InfluxDBStudio This is a gui for Windows. maybe that helps

As far as I remember, you have to end each influx command with a semicolon.

CREATE DATABASE openhab_db;
CREATE USER myusername WITH PASSWORD 'mypassword' WITH ALL PRIVILEGES;
CREATE USER openhab WITH PASSWORD 'myopenhabpassword';
CREATE USER grafana WITH PASSWORD 'mygrafanapassword';
GRANT ALL ON openhab_db TO openhab;
GRANT READ ON openhab_db TO grafana;

Semicolon does not work, too. Still searching for a solution.

Look in /var/log/syslog when you type in your commands. InfluxDB normally logs there. You might see a clue as to what is going wrong if you look at the log.

1 Like

ERR: unable to parse authentication credentials

I had the same issue. You have to disable auto-authentication.

sudo nano /etc/influxdb/influxdb.conf

in the file under http you find:

auth-enabled = true

change this to false

there is no need for semicolons.

1 Like

Hi if i can please get some help :slight_smile:

so Grafna is working and giving me some grhapes , i am trying to insert a webelemnt
but i am getting 192.168.1.103 refused to connect.

sitemap

Text item=Charts icon="calendar"{
Switch item=weatherChartPeriod label="Chart Period" mappings=[1="Day"]
Webview url="/static/chartsDay.html" height=33 visibility=[weatherChartPeriod=="1"]

Items:

String Charts
String weatherChartPeriod

charts.css

.container iframe {
  width: 100%;
  height: 400px;
}

.container {
  width: 98%;
  margin: 0 auto;
}

h2 {
  text-align: center;
}

chartsDay.html:

   " <!DOCTYPE html>
<html>
<head>
        <meta http-equiv="Content-type" CONTENT="text/html; charset=utf-8">
        <link rel="stylesheet" type="text/css" href="charts.css" />
</head>
    <div class="container">
        <iframe src="http://192.168.1.103:3000/d-solo/4gt0dIhZz/temps?orgId=1&from=1569917887296&to=1569961087298&panelId=4"></iframe>
    </div>
  </br>
    <div class="container">
        <iframe src="http://192.168.1.103:3000/d-solo/4gt0dIhZz/temps?orgId=1&from=now-1h&to=now&panelId=4"></iframe>
    </div>
</html>
"

i dont understand what i need to to with the URL from the HTML?

<iframe src="http://192.168.1.103:3000/d-solo/4gt0dIhZz/temps?orgId=1&from=1569917887296&to=1569961087298&panelId=4" width="450" height="200" frameborder="0"></iframe>

this is what i got from grfana how do i make it fit my web elemnt , i tried many ways i am getting
192.168.1.103 refused to connect. in GUI

logs look ok , please help :slight_smile:

Hello,

I have been bumping into this for a long time myself… @Matthias_Kaufmann, did you eventually understand how to get that simple feature working?
@ThomDietrich, you cited this in your post, I’m sure you’ve tried it. Does it work for you?

Thanks,

Hello,
I hope to find some clarification about my items not showing up in grafana.
I am running OH2.5.0 M3 and Grafana/influxdb on a RPi3b+
I don’t see anything causing an issue in my log file.
Very few of my items appear in my Grafana, demo items and astro items and once a handful of my Lutron devices but then the Lutron also disappeared.
My data source is working.
I am posting my .persist file below.
I will produce any other files needed to help.
Influxdb.persist located under conf dir in the persistence directory.

The database URL, e.g. http://127.0.0.1:8086 or https://127.0.0.1:8084 .

Defaults to: http://127.0.0.1:8086

url=http(s)://:

url=http://192.168.0.34:8086

The name of the database user, e.g. openhab.

Defaults to: openhab

user=

user=openhab

The password of the database user.

password=

password=***********

The name of the database, e.g. openhab.

Defaults to: openhab

db=openhab_db

db=url=http://localhost:8086

db=openhab_db
retentionPolicy=autogen

Enable authentication in the [http] section of the configuration file /etc/influxdb/influxdb.conf:

[http]
enabled = true
bind-address = “:8086” # change to a specific interface if needed
auth-enabled = true # will enforce authentication

Thank you in advance for any help.

Maybe I am just blind, but I don’t see your persist file in your post. :confused:

LMAO!
I am sorry, posted cfg by mistake.
They all tend to run together at times.

Strategies {
everyMinute : “0 * * * * ?”
everyHour : “0 0 * * * ?”
everyDay : “0 0 0 * * ?”
}

Items {
* : strategy = everyChange, restoreOnStartup
samsungtv_* : strategy = everyChange, restoreOnStartup

}

@BrutalBirdie thank you for your super fast response

Did you check the database if questioned Item is persisted? (via. cli not grafana)
This is my persist file btw.
I had this mistake once where I named my persist file influx.persist and not influxdb.persist maybe check that one as well.
https://community.openhab.org/t/solved-influxdb-openhab-stores-no-data/33719/53

// Persistence Strategien haben einen Namen und eine Definition
Strategies {
    everyHour : "0 0 * * * ?"
    everyDay  : "0 0 0 * * ?"

    // Wenn bei einem unten definierten Item keine Strategie angebeben ist,
    // wird die Default-Liste angewendet
    default = everyChange
}

/*
 * Each line in this section defines for which item(s) which strategy(ies)
 * should be applied. You can list single items, use "*" for all items or
 * "groupitem*" for all members of a group item (excl. the group item itself).
 */
Items {
    // Speichere die Daten aller Items jeden Tag (veryDay), bei jeder Änderung (everyChange) und
    // ordne den Items bei einem Neustartand den letzten Wert zu (restoreOnStartup)
    * : strategy = everyChange, everyDay
}

I do get this error/warning after a reboot:
[WARN ] [nce.extensions.PersistenceExtensions] - There is no queryable persistence service registered with the id ‘influxdb’
I assumed that the persist file hadn’t been loaded yet, after it settle’s out it goes away.
Otherwise I will cut and paste your persist file and see if that makes a difference.
file is named influxdb.persist

This line seems fishy :fish:
I flew over the docs

<groupName>* - all members of this group will be persisted, but not the group itself. If no strategies are provided, the default strategies that are declared in the first section are applied. Optionally, an alias may be provided if the persistence service requires special names (e.g. a table to be used in a database, a feed id for an IoT service, etc.) Note that * is NOT a wildcard match character in this context.

Is your group really named samsungtv_ ? Persistence | openHAB
I assume you have like samsungtv_X, samsungtv_Y, samsungtv_Z and you expected it to work like a RegEx?
Try to list your groups in full name with your * like samsungtv_X*