pkaramol
pkaramol

Reputation: 19342

Calculate request rate for prometheus

I have a sample web app written in python.

Each container reports (using prometheus-python client library) its total requests.

Therefore, since I have 2 replicas, when querying in prometheus dashboard for my_metric_request I get 2 time series (one for each pod)

myapp_requests_overall_total{container="myapp", endpoint="metricsport", instance="172.17.0.4:8282", job="my-service-exposing-the-metrics", namespace="default", pod="my-app-ff75c4784-xxtx4", service="my-service-exposing-the-metrics"}
243
myapp_requests_overall_total{container="myapp", endpoint="metricsport", instance="172.17.0.4:8282", job="my-service-exposing-the-metrics", namespace="default", pod="my-app-ff75c4784-dk40", service="my-service-exposing-the-metrics"}

My question is how can I produce (having the request sum) a metric that will indicate the rate of the requests?

Upvotes: 1

Views: 2007

Answers (1)

Marc ABOUCHACRA
Marc ABOUCHACRA

Reputation: 3463

You need to aggregate the result by one (or more) usefull label.
For example, if you want to monitor the average number of request by job, then you'll have the following :

sum(rate(myapp_requests_overall_total[5m])) by (job)

Upvotes: 1

Related Questions