I am trying to show top 10 most frequent tags in Grafana, but I can't make it. The schema of my measurement (which is called mymeasurement
) in InfluxDB is as follows:
timestamp | value | mytag
-------------------------
time_1 | 1 | tag_1
-------------------------
time_2 | 1 | tag_2
-------------------------
time_3 | 1 | tag_1
-------------------------
time_4 | 1 | tag_3
-------------------------
time_5 | 1 | tag_2
where value
is the field in InfluxDB, and mytag
is the tag.
Now, I can show all the tags with times of their appearance using the following query in Grafana:
SELECT count(value) FROM mymeasurement WHERE time > now() - 1h GROUP BY mytag
But when the measurement get larger and larger (with more and more tags), Bar Gauge in Grafana shows all the tags, which gets annoying over time. I tried to use this query to get top 10 tags:
SELECT top(mycount, mytag, 10) FROM (SELECT count(value) AS mycount FROM mymeasurement WHERE time > now() - 1h GROUP BY mytag)
It looked great in the command line influx
tool, but in Grafana it shows two meaningless bars. How should I address this problem?