简体   繁体   English

如何在 Prometheus/Grafana 中不指定 label 的情况下通过唯一标签计算指标数量?

[英]How can I calculate the number of metrics by unique labels without specifying a label in Prometheus/Grafana?

Because all URLs are dynamic, I cannot specify a specific URL when I group labels.因为所有 URL 都是动态的,所以当我对标签进行分组时,我无法指定特定的 URL。 Because every time a unique URL can appear.因为每次都会出现一个独特的URL。

Here's an example from metrics.这是来自指标的示例。

16:00:00
http_trace{method="GET",status="404",uri="/actuator/conditions/777",} 1.0
http_trace{method="GET",status="200",uri="/actuator/conditions",} 3.0
http_trace{method="GET",status="200",uri="/actuator/test",} 3.0
http_trace{method="GET",status="200",uri="/actuator/beans",} 3.0

16:00:30
http_trace{method="GET",status="404",uri="/actuator/conditions/777",} 4.0
http_trace{method="GET",status="200",uri="/actuator/conditions",} 2.0
http_trace{method="GET",status="200",uri="/actuator/test",} 6.0
http_trace{method="GET",status="200",uri="/actuator/beans123",} 7.0

How can I make Promethus or Grafana Query - So that I get that number.?我怎样才能使 Promethus 或 Grafana 查询 - 以便我得到那个号码。?

uri="/actuator/conditions/777" -> 5.0
uri="/actuator/conditions" -> 5.0
uri="/actuator/test" -> 9.0
uri="/actuator/beans" -> 3.0
uri="/actuator/beans123" -> 7.0

Thanks.谢谢。

If you want to calculate a sum of metric values grouped by some label:如果要计算按某些 label 分组的指标值的总和:

sum(http_trace) by (uri)

This will give you the following result:这将为您提供以下结果:

{uri="/actuator/conditions/777"} 5.0
{uri="/actuator/conditions"} 5.0
{uri="/actuator/test"} 9.0
{uri="/actuator/beans"} 3.0
{uri="/actuator/beans123"} 7.0

If you want to calculate 'the number of metrics by unique label':如果要计算“唯一标签的指标数量”:

count(http_trace) by (uri)

And the result will be:结果将是:

{uri="/actuator/conditions/777"} 1.0
{uri="/actuator/conditions"} 1.0
{uri="/actuator/test"} 1.0
{uri="/actuator/beans"} 1.0
{uri="/actuator/beans123"} 1.0

This shows how many metrics with unique label sets are there, grouped by uri label.这显示了有多少具有唯一 label 集的指标,按uri label 分组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Prometheus 查询中“加入”两个指标? - How can I 'join' two metrics in a Prometheus query? 如何获得使用Prometheus搁置服务器的请求数? - How can I get the number of requests to rest server with prometheus? 如何在基于 sysdig 指标标签的 grafana 仪表板中创建下拉菜单 - How to create a drop down in grafana dashboard which is based on sysdig metrics label 监视和警报度量标准中的普罗米修斯异常 - Monitor and alert prometheus anomaly in number of metrics 如何用grafana使用prometheus监控多个mysql? - how to Monitoring multiple mysql using prometheus with grafana? Graphite 或 Grafana 可以用来监控 pyspark 指标吗? - can graphite or grafana used to monitor pyspark metrics? 无法使用普罗米修斯收集 docker 指标 - can't collect docker metrics using prometheus 如何在普罗米修斯中收集 WSO2AM 指标? - How to gather WSO2AM metrics in prometheus? 无法使用Prometheus在grafana仪表板中获取kubernetes集群的系统服务内存和cpu指标 - unable to get the system service memory and cpu metrics of kubernetes cluster in grafana dashboard using prometheus Grafana + Prometheus:显示事件发生频率的单个统计信息 - Grafana + Prometheus: Display single stat of how often an event occurred
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM