In Prometheus, given below metric definition, how do I render a table for top 5 recurring devices part of the metric series?
top_5_noisy_devices:
{ "device" : "1234", "type" : "foo"}
{ "device" : "1234", "type" : "foo"}
{ "device" : "1234", "type" : "foo"}
{ "device" : "2345", "type" : "foo"}
{ "device" : "4231", "type" : "foo"}
{ "device" : "4354", "type" : "foo"}
I want to render a table in Grafana for the above labels to show that device 1234 is the noisy device in the selected time duration. I tried topk operator but it renders more than 3. ( I see 100's of rows in table instead of just 3) https://www.robustperception.io/graph-top-n-time-series-in-grafana claims to support topk in Grafana. But I fail to understand how to adapt it to a table.
I used below approach to display a table.
Add a Panel in Grafana (either as table or a Pie Chart of your choice) and used below query
topk(5,round(increase(top_5_noisy_devices{type="Foo"}[$interval])))
And selecting any interval dropdown using the variables fetches the topk data for the specific period.