如何通过使用普罗米修斯直方图的标签分组来计算平均值?
How to calculate average by labels grouping with prometheus histograms?
我在我的程序中有批处理数据库查询,我想根据批大小测量完成批处理查询的平均时间,目前我有
rate(batched_query_duration_seconds_sum{job="myprogram"}[5m]) / rate(batched_query_duration_seconds_count{job="myprogram"}[5m])
该指标具有标签 batch_size
,我认为正确的查询应该类似于
rate by (batch_size) (batched_query_duration_seconds_sum{job="myprogram"}[5m]) / rate by (batch_size) (batched_query_duration_seconds_count{job="myprogram"}[5m])
但这是语法错误。我怎样才能做到这一点?谢谢
尝试以下查询:
sum(rate(batched_query_duration_seconds_sum{job="myprogram"}[5m])) by (batch_size) / sum(rate(batched_query_duration_seconds_count{job="myprogram"}[5m])) by (batch_size)
我在我的程序中有批处理数据库查询,我想根据批大小测量完成批处理查询的平均时间,目前我有
rate(batched_query_duration_seconds_sum{job="myprogram"}[5m]) / rate(batched_query_duration_seconds_count{job="myprogram"}[5m])
该指标具有标签 batch_size
,我认为正确的查询应该类似于
rate by (batch_size) (batched_query_duration_seconds_sum{job="myprogram"}[5m]) / rate by (batch_size) (batched_query_duration_seconds_count{job="myprogram"}[5m])
但这是语法错误。我怎样才能做到这一点?谢谢
尝试以下查询:
sum(rate(batched_query_duration_seconds_sum{job="myprogram"}[5m])) by (batch_size) / sum(rate(batched_query_duration_seconds_count{job="myprogram"}[5m])) by (batch_size)