Skip to content
Advertisement

SQL request for a JSON file

I am using node-red and influxDB with it. Basically I am running node-red (which execute a python code), with node-red I am getting a data from gauge strain cell, and I have them with a json format as follows :

{ “X” : “-0.18102575652004627”,“Y” : “0.8599837901151595”}

That data is stored inside influxDB, then I would like to display them in Grafana. The X value will be the X axis and Y value the Y axis.

How can I make a SQL query request to get X and Y independently.

When I use :

SELECT * FROM 

I get this data as a result:

1574439673173046787 { "X" : "0.5331351951053145","Y" : "0.5351730541177269"}
1574439674038377239 { "X" : "0.23836196817466518","Y" : "0.2391236764227406"}
1574439676107561878 { "X" : "-0.6959993930530565","Y" : "-0.6942994126488101"}

which is the timestamp for each acquisition. But I do find a way to select only X for example for a given timestamp.

Thank you

Advertisement

Answer

1.) InfluxDB doesn’t support SQL, but InfluxQL (syntax is similar, but it is not a SQL). Please check InfluxDB doc for correct time condition syntax – there is a few options (absolute/relative): https://docs.influxdata.com/influxdb/v1.7/query_language/data_exploration/#time-syntax

2.) It looks like your X, Y are a tags, but Grafana needs fields. Only fields can be visualized. Tags are used for filtering. You should to change measurement schema/node-red code.

3.) Grafana supports timeseries data by default. X value will be the X axis and Y value the Y axis – it doesn’t look like a timeseries visualization. You will have problem to do this type of graph in Grafana. You may will need to code own custom panel for that.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement