如何使用 Istio Prometheus 指标计算每分钟的请求数?
How to calculate requests per minute using Istio Prometheus metrics?
我想计算每分钟的请求数,按服务名称汇总。
我正在使用以下查询,但我不确定它是否正确。
sum(increase(istio_requests_total{destination_workload_namespace="falabella"}[1m])) by (destination_workload)
看起来是正确的。
另一个查询是:
60 * sum(rate(istio_requests_total{destination_workload_namespace="falabella"}[1m])) by (destination_workload)
如文档所述,它们是等价的:https://prometheus.io/docs/prometheus/latest/querying/functions/#increase
在计算 per-minute 请求率时使用 increase(istio_requests_total[1m])
而不是 60 * rate(istio_requests_total[1m])
在技术上更正确,因为 istio_requests_total
是一个具有整数值的计数器(例如自上次计数器重置以来的请求总数)。预计在最后一分钟 increase()
整数计数器必须 return 整数值,而 rate()
可能 return 小数值。
不幸的是,由于外推,Prometheus 可能 return increase()
整数计数器的小数结果。从头开始查看 this issue for details. Additionally, increase()
and rate()
in Prometheus may miss counter increase for slow-changing counters - see this comment and this article for technical details. Prometheus developers are going to fix these issues - see this design doc. In the mean time it is possible to use VictoriaMetrics, which solves these issues in rate() and increase() 个函数。
我想计算每分钟的请求数,按服务名称汇总。
我正在使用以下查询,但我不确定它是否正确。
sum(increase(istio_requests_total{destination_workload_namespace="falabella"}[1m])) by (destination_workload)
看起来是正确的。 另一个查询是:
60 * sum(rate(istio_requests_total{destination_workload_namespace="falabella"}[1m])) by (destination_workload)
如文档所述,它们是等价的:https://prometheus.io/docs/prometheus/latest/querying/functions/#increase
在计算 per-minute 请求率时使用 increase(istio_requests_total[1m])
而不是 60 * rate(istio_requests_total[1m])
在技术上更正确,因为 istio_requests_total
是一个具有整数值的计数器(例如自上次计数器重置以来的请求总数)。预计在最后一分钟 increase()
整数计数器必须 return 整数值,而 rate()
可能 return 小数值。
不幸的是,由于外推,Prometheus 可能 return increase()
整数计数器的小数结果。从头开始查看 this issue for details. Additionally, increase()
and rate()
in Prometheus may miss counter increase for slow-changing counters - see this comment and this article for technical details. Prometheus developers are going to fix these issues - see this design doc. In the mean time it is possible to use VictoriaMetrics, which solves these issues in rate() and increase() 个函数。