Reputation: 19342
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
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