InfluxDB+Grafana persistence and graphing

influxdb
graphs
grafana
Tags: #<Tag:0x00007fe056ebdbb8> #<Tag:0x00007fe056ebda28> #<Tag:0x00007fe056ebd4b0>

(bccrew) #714

@rlkoshak
I have checked that documentation already but I still don’t see how I should achieve my goal.

Just posting a link to a a documentation page is not very (user) friendly imho. If you can help with the specific problem, please do. But if you don’t want to or cannot, don’t just post to post… I know LMGTFY or RTFM but if that still is not clear enough for me to understand, isn’t that what asking for help or a forum is meant for?


(Rich Koshak) #715

Persistence Configuration

The information below allows you to determine which Item states are persisted, when they are persisted, and where they are stored.

Persistence Triggers

The persistence of an Item’s state may be triggered when that Item changes state or when the Item is updated (even if its state did not change). Persistence may also be triggered by a time-related event (see Cron Persistence Triggers below).

Cron Persistence Triggers

openHAB uses Quartz for time-related cron events. See the Rules article for more information.

Below you will find a complete example persistence configuration file:

// persistence strategies have a name and definition and are referred to in the "Items" section
Strategies {
        everyHour : "0 0 * * * ?"   // <--------
        everyDay  : "0 0 0 * * ?"  // <--------

        // if no strategy is specified for an Item entry below, the default list will be used
       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 {
        // persist the Item state of Heating_Mode and Notifications_Active on every change and restore them from the db at startup
        Heating_Mode, Notifications_Active: strategy = everyChange, restoreOnStartup

        // additionally, persist all temperature and weather values every hour
        Temperature*, Weather* : strategy = everyHour   // <---------------------
}

Everything I would have typed in to answer your question are right there in the documents.

So I could have spent 10 minutes retyping the exact same thing that is in the docs already, or I could point you to the part of the docs that gives you the exact answer to your question and spend that 10 minutes helping someone who has a question that isn’t already pretty fully documented.

I’ve bolded the most important text and added // <------ to point to the lines in the comprehensive example that specifically answer your exact question.

Just asking a basic question without showing any indication that you have even looked at the docs, done a search of the forum, or even looked at the example in the OP, shows a lack of respect for the time of the volunteers spend on this forum trying to help users, IMHO.

If you DID look at the docs before posting your question, then say so in your original question. Explain what your confusion is and where the docs are not clear. Then we can actually fix the docs to make them more clear.

We don’t have enough volunteers here to spend hours and hours rewriting the docs as a reply every time a user asks a question whose answer is in docs.


(bccrew) #716

My apologies,

A part of my original question was lost. I thought my persistence file was there but clearly it isn’t…

I currently have this:

Strategies {
    everyMinute : "0 * * ? * *"
}
Items {
    BroadlinkA1192168112_Temperature  : strategy = everyChange, everyMinute, restoreOnStartup
}

Seems to be working now, the problem was the refresh rate of the webif of grafana


(Aymeric) #717

Perhaps this tutorial needs to be updated a bit:

Raspberry PI is now officialy supported so I switched to the official repo instead of https://github.com/fg2it/grafana-on-raspberry.

When doing so, anonymous access was not working.
It needed two more changes in the configuration ini file to work with the latest version

[auth.anonymous]
# enable anonymous access
enabled = true
# specify organization name that should be used for unauthenticated users
org_name = YOURORGANIZATION
# specify role for unauthenticated users
org_role = Viewer

I don’t remember when the org name is set, but you can find it in the grafana settings, under server admin menu.

Aymeric


(Martin) #718

A long thread …

I have running influx and grafana on my Raspberry, and was able to see a “live” graph (5s intervall) on a website (local PC), URL like:
http://192.168.:3000/d/Il-rTUzRk/e-power-kwh-live?orgId=1&panelId=2&fullscreen&from=now-5m&to=now&refresh=5s

I will use this “live graph” on a sitemap (actuall no habpanel), i this possible? How :wink:
Or do I need that Grafana create png-files and I have to show these (but: not easy for a 5s intervall …)

Also: On the PC I have also to login into Grafana to see the graph, is there a “good” way that this not needed?


(John Schmitz) #719

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

Persistence: Possible to specify both time and value with postUpdate?
(hendrik ) #720

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?


(Arne) #721

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?


[SOLVED] MQTT & influx, no datapoints in grafana
(Udo Hartmann) #722

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.


(John Schmitz) #723

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

(Andrew Rowe) #724

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


(John Schmitz) #725

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.