Help with counting results from a json data source query

I’m looking for a bit of help with counting unique results of a json query and displaying as a stat.

I have a json data source that amongst other things used to shows a list of docker containers that I have running. I’m able to successfully use this data source to display a table of these, using the query $.[‘docker’][‘details’][‘containers’][?(@.status== ‘started’)].name

I’d like to be able to show a stat with the number of containers running, rather than a list. I could do that by counting the unique results of the above query. This is as far as my knowledge goes though, so my question is does any one know how I can count the unique results of the existing query?

hi @random1471

You should be able to do this. Do you have this query working in Grafana? Can you show what the data looks like when you inspect it / use the table panel plugin?

You should be able to perform a transformation that reduces your rows to their count, and then use a Stat panel to display count

This topic was automatically closed after 365 days. New replies are no longer allowed.