We have moved at community.getvera.com

Author Topic: Using Grafana with DataYours  (Read 353 times)

Offline ericferon

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Using Grafana with DataYours
« on: February 26, 2019, 11:02:15 am »
I've installed DataYours on my VeraLite (running the last firmware 1.7.1040) a few days ago, and I would like to use Grafana to access the Whisper database located on my Vera.
As I read in another thread, I copied, from DataYours Github repository, the file graphite_cgi.lua into Vera's directory /etc/cmh-ludl.
But when I create a Graphite datasource in Grafana, pointing to URL http://192.168.1.34:3480, with access type "Server", no authentication and Graphite version 0.9, and "Save and Test", I get an error message "HTTP Error Bad Gateway".
Any idea of what is missing or wrong ?
Thanks in advance,
Eric

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Using Grafana with DataYours
« Reply #1 on: February 28, 2019, 01:12:41 pm »
The file you used is a WSAPI cgi file, and this is not supported by Vera.  Was there some documentation somewhere which suggested that it should work?

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline ericferon

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Using Grafana with DataYours
« Reply #2 on: March 01, 2019, 03:32:21 am »
Yes, in your reply #21, dated October 17, 2016 in thread http://forum.micasaverde.com/index.php/topic,39612.15.html.
But I probably misunderstood the context.
So, this file graphite_cgi.lua does not solve my problem, as a conclusion.
What do I need to do ?
Best regards,

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Using Grafana with DataYours
« Reply #3 on: March 01, 2019, 05:26:55 am »
Yes, in your reply #21, dated October 17, 2016 in thread http://forum.micasaverde.com/index.php/topic,39612.15.html.
But I probably misunderstood the context.

Yes, afraid so.  That thread, and indeed this one, is in the context of openLuup, which was designed to overcome many of the shortcomings of Vera.

Quote
So, this file graphite_cgi.lua does not solve my problem, as a conclusion.
What do I need to do ?

No, it doesn't. The problem is that to write an HTTP handler within Vera's Luup, the request has to be of the form:

Code: [Select]
http://VeraIP/port_3480/data_request?id=...

But you can't configure Grafana to generate such a request, because it wants to send things like:

Code: [Select]
http://VeraIP/metrics/find?query=*

The best that I could manage just now was to get it to generate:

Code: [Select]
http://VeraIP/port_3480/data_request/metrics/find?query=*

But that's not good enough, because it has no id=... parameter.

What you'd need to do is:

(2) above would allow the use of that CGI file directly.  FWIW, I've asked whether the WSAPI CGI gateway can be included in a future Vera release, but who knows whether/when that would happen.

So (1) is what needs to be done.  I never got around to it because openLuup was my route around the problem.  Of course, that's a solution for you too if you have a spare machine (or spare capacity) to run it.
« Last Edit: March 01, 2019, 06:12:11 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline ericferon

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Using Grafana with DataYours
« Reply #4 on: March 01, 2019, 10:44:24 am »
OK, but there is a graphite plugin in Grafana (http://docs.grafana.org/features/datasources/graphite/), that I used to create the link to DataYours.
I guess (and I hope !) that this plugin "transforms" the usual Grafana request to the one expected by any Graphite server, like DataGraph.
It expects, as "Url" parameter, the HTTP protocol, IP, and port of the graphite-web or graphite-api install.
In DataYours, isn't it "http://VeraIP:3480" ?
Best regards,
Eric

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Using Grafana with DataYours
« Reply #5 on: March 01, 2019, 11:18:27 am »
OK, but there is a graphite plugin in Grafana (http://docs.grafana.org/features/datasources/graphite/), that I used to create the link to DataYours.

Yes, that's what I was using too.

Quote
I guess (and I hope !) that this plugin "transforms" the usual Grafana request to the one expected by any Graphite server, like DataGraph.
It expects, as "Url" parameter, the HTTP protocol, IP, and port of the graphite-web or graphite-api install.

Yes, and that request is what is handled by the graphite_cgi.lua file.  But in order to run that CGI you need to go through an HTTP server which supports it, and, out of the box, Vera doesn't.

Quote
In DataYours, isn't it "http://VeraIP:3480" ?

No, that's deprecated in the latest firmware releases.  In fact, under some security settings, that port is actually closed.  You have virtual access to that through Vera's port 80 using the /port_3480 syntax.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline ericferon

  • Newbie
  • *
  • Posts: 4
  • Karma: +0/-0
Re: Using Grafana with DataYours
« Reply #6 on: March 12, 2019, 01:52:13 pm »
Using http://veraIP/port_3480 instead of http://veraIP:3480 already works better, as the datasource is recognized in Grafana.
But indeed, no metrics can be imported.
I guess that it could be possible to develop a grafana datasource plugin, that implements the query method needed by Datayours (cfr http://docs.grafana.org/plugins/developing/datasources/).
Anyway, thank you for your help.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: Using Grafana with DataYours
« Reply #7 on: March 12, 2019, 02:04:14 pm »
Yes, any JavaScript savvy person should be able to make a datasource plugin, but that's outside my skillset, I'm afraid.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.