I have a network of sensors passing data to influxdb. Each sensor has a unique ID, used as a tag in Influx.
Let’s say we start with 100 sensors (and therefore 100 different tags). Over time, some sensors get damaged, unplugged or otherwise incapacitated.
What I would like to do is show a chart over time of how many distinct tags are reporting data.
I’m relatively new to Grafana, but I’ve been able to solve most of the other (self created) problems I’ve run into. However, I’m totally stuck on how to approach this one.
Why you are creating new tag for each sensor and not just tag value? It will help if you show example of your DB structure, because it looks like inefficient InfluxDB design.
You need subqueries (keywords to google and learn - influxdb subquery). Inner query will return aggregated values per tag and outer query count inner results. Example - not a copy paste query - syntax can be wrong - it is just to give you idea:
SELECT COUNT(mean)
FROM (
SELECT MEAN("field")
FROM "measurement"
WHERE $timeFilter
GROUP BY time($__interval), "tag"
)
GROUP BY time($__interval)
SELECT COUNT(mean)
FROM (
SELECT mean("myField") FROM "myMeasurements" WHERE $timeFilter GROUP BY time($__interval), "tag"
)
GROUP BY time($__interval)
Hi, I suppose I am even newer to Grafana but do have a similar problem. Your help would be greatly appreciated. I have a table with a single field :“MAC” and the time of course. Now all I want to query is the number of distinct MACs within a certain time-intervall. I suppose that also requires the nested query but I can’t figure out how it is done.
Cheers