I have some data from different sensors that can be plugged in and out, each sensor has unique ID.
Is there any way to draw all the time series for all the sensors in the Grafana database? I don't want to enumerate 50+ sensors, especially considering the fact that they can come and go.
There are not enough details on measurements and tags in your database and how you want to draw time series: all in one graph or one per graph.
I assume you have sensorID as tag in measurement.
For one sensor per graph solution may look like this:
Create template variable sensorID and fill it from query
SHOW TAG VALUES FROM "yourMeas" WITH key="sensorID"
Create Graph panel on dashboard with metrics query using template variable. Smth like:
SELECT mean(value) FROM "yourMeas" WHERE "sensorID" =~ /$sensorID$/ AND $timeFilter GROUP BY time(5m) fill(null)
Select sensorID template variable name in Repeat panel 'General' graph edit tab to repeat graph for all values of your $sensorID template variable. Alternatively you can set Repeat for in row options settings to repeat rows instead of graph panels.
For all sensors in one graph you don't need all these 'repeat for' - it's enough to add sensorID tag to GROUP BY in query:
SELECT mean(value) FROM "yourMeas" WHERE $timeFilter GROUP BY time(5m), "sensorID" fill(null)
and use tag value in alias: for example set ALIAS BY to $tag_sensorID
Related
I query all measurements from Influx database like so:
http://localhost:8086/query?pretty=true&db=boatdata&q=SELECT value FROM /.*/ LIMIT 1
Works fine. However, instead of LIMIT 1 I need to get values for all the measurements where value from one measurement=x, so I’d expect something like
SELECT value FROM /.*/ WHERE measurement1.value=x but it doesn’t work. I hope it makes sense. Any idea how to make it work? Thanks.
...to explain it better: in the first query (http://localhost…) I listed in this post I get a 1 record for all the measurements. But I want to get 1 record for all the measurements where value from measurement1 (one of the measurements) equals X.
This is impossible using InfluxQL. All measurements you ask are different series of data - so they are not grouped together in one table.
Idea of InfluxDB is that measurements are separate "tables" which are indexed by time and tag keys. I suggest you change your database architecture by writing values into different value fields.
You should have your data in one measurement to make query like you want.
You can move all your data from other measurements to one measurement for example by:
select "value" as "value1" from "measurement1" into "measurement" group by *
For each "measurement1" moved into "measurement" which will collect many value fields.
Then you will be able to make a query:
select * from "measurement" where "value1"=5
The query above should give you all value fields moved into "measurement" with the same timestamp where field "value1"=5.
Tip: If you have value1,value2,value3 in your measurement then you can use regex like:
select /value/ from "measurement" where "value1"=5
To avoid receiving tag key values or field values which you do not want.
I need to chart physical measurements using Influx. All measurements are stored as series inside a single Influx "measurement".
Some are "current" values like temperatures, other are things like energy meter readings.
The problem is that these need different queries in order to produce visually attractive output. Charting the meter readings as current power is possible using the DIFFERENCE function.
SELECT difference(max("value")) AS "diff_value"
FROM "volkszaehler"."autogen"."data"
WHERE time > :dashboardTime:
GROUP BY time(1d), "title" FILL(linear)
For other values like temperatures the selection should be mean("value") without the difference.
Is there a way to "union" result sets in InfluxDB similar to mysql in order to display them in a single chart in Chronograf?
Sorry, this isn't possible and new functionality isn't being added to InfluxQL while Flux is being actively worked on.
https://github.com/influxdata/flux
InfluxDB's SHOW SERIES query returns a list of all series-tag-value combinations existing in the database.
How can I get a list of just the series' "base names" (without tags)?
Series without tags is just a measurement.
SHOW MEASUREMENTS [ON <database_name>]
In InfluxDB v1.3, I have a measurement with one field and a tag that can take two values.
I would like to compute (x where mytag=y) - (x where mytag=z), using the last value of each series when needed (something like an http://code.kx.com/wiki/Reference/aj). I would like to do this in one query, if possible.
If the above is not possible, is there a different schema (e.g. using separate measurements) where what I would like to do is feasible? If so, can you please elaborate on the structure and the query?
SELECT difference(mean(x))
FROM <measurement>
WHERE time > now() - 1h and (mytag='y' OR mytag='x')
GROUP BY time(60s), mytag
Functions like difference require an aggregate query (group by time()) as well as an aggregation function for the values within the grouped window (mean above).
Difference then shows the differences between sequential aggregated values for the time period specified, additionally grouped by the two tag values specified.
These can be adjusted depending on your data.
when I use influxdb as the datasource, In the graph metrics define, I find that if I add a column after the "and" label, (like: latency_scope, type), data response is correct but legend display undefine, and there is no date display on the dashboard.
raw query is like this, however, it does not work.
"select latency_scope, uri, sum(sum_count) from "latency" where $timeFilter group by time($interval), latency_scope, uri fill(0) order asc"
Can grafana make multiple group by?
thx
I just checked the code, and that's true it does not support multiple group by, but it is not difficult to modify the source code to support.