Search code examples
prometheusgrafanapromql

How to use promql group by without using aggregate functions in Grafana


I am trying to create a query that groups the data by "Api" field and selects a value field by using prometheus and grafana.

My sample query (promql) is max (application_apidbacesscount_total) by (Api) [30m:1m]. This works for getting max value with grouping the data by "Api" field.

How can i do that using grafana's panel? Is it possible to give Grafana a base query and modify it with panel fields?


Solution

  • You have to add a new widget and add the query:

    max(rate(application_apidbacesscount_total[$__range])) by (Api)
    

    enter image description here

    Using [$__range] instead of a fixed range will apply the values of rage selector from Grafana