Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query multiple metrics in one Prometheus HTTP Call

I want to make one http call to Prometheus server and get the following:

  • Multiple metrics
  • Calculate rate for all metrics within last 30 seconds

I have the following query which works, it requests the results of multiple prometheus metrics in one call for last 30 seconds. I`m just not sure how to extend this query to also calculate the rate for all these metrics. Can anyone help?

/api/v1/query?query={__name__=~"metric1|metric2|metric3",service=~"testservice"}[30s]

I want to do something like

    /api/v1/query?query={rate(__name__=~"metric1|metric2|metric3",service=~"testservice"}[30s])
like image 573
Hussain Moiz Avatar asked Oct 27 '25 14:10

Hussain Moiz


1 Answers

You need to put the rate before the labels. This should work:

/api/v1/query?query=rate({__name__=~"metric1|metric2|metric3",service=~"testservice"}[30s])

Note that you must have at least one datapoint in the 30s period for each of the metrics.

like image 193
Tomy8s Avatar answered Oct 30 '25 12:10

Tomy8s



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!