0
votes

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.

1

1 Answers

3
votes

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:

  1. Create template variable sensorID and fill it from query SHOW TAG VALUES FROM "yourMeas" WITH key="sensorID"
  2. 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)

  3. 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