简体   繁体   English

Java Micrometer - 如何处理 *_bucket 类型的指标

[英]Java Micrometer - What to do with metrics of type *_bucket

Quick question regarding metrics of type *_bucket please.请快速询问有关 *_bucket 类型指标的问题。

My application generates metrics, like those below:我的应用程序生成指标,如下所示:


# HELP http_server_requests_seconds  
# TYPE http_server_requests_seconds histogram
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.005592405",} 273.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.006990506",} 797.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.008388607",} 2638.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.009786708",} 3543.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.011184809",} 3932.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.01258291",} 4154.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.013981011",} 4279.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/health",le="0.015379112",} 4380.0

and

# HELP resilience4j_circuitbreaker_calls_seconds Total number of successful calls
# TYPE resilience4j_circuitbreaker_calls_seconds histogram
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.001",} 0.0
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.001048576",} 0.0
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.001398101",} 0.0
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.001747626",} 0.0
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.002097151",} 0.0
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.002446676",} 0.0
resilience4j_circuitbreaker_calls_seconds_bucket{kind="successful",name="someName",le="0.002796201",} 0.0

I believe they are really useful, but unfortunately, I do not know what to do with them.我相信它们真的很有用,但不幸的是,我不知道如何处理它们。

I tried some queries such as rate(http_server_requests_seconds{_bucket_=\\"+Inf\\", status=~\\"2..\\"}[5m]) , but does not seems to bring anything valuable out.我尝试了一些查询,例如rate(http_server_requests_seconds{_bucket_=\\"+Inf\\", status=~\\"2..\\"}[5m]) ,但似乎没有带来任何有价值的东西。

May I ask what is the proper way to use those metrics of type *_bucket, for instance, how to build Grafana dashboards and visuals that are the best suited for those *_bucket please?请问使用 *_bucket 类型的指标的正确方法是什么,例如,如何构建最适合这些 *_bucket 的 Grafana 仪表板和视觉效果?

Thank you谢谢

you can find 99th percentile/95th percentile of the latency of given endpoint using this metric and can use histogram_quantile function for that.您可以使用此指标找到给定端点延迟的第 99 个百分位/第 95 个百分位,并且可以使用 histogram_quantile 函数。 eg For 99th percentile : histogram_quantile(0.99, sum(rate(http_server_requests_seconds_bucket{exception="None", uri = "/your-uri"}[5m])) by (le))例如对于第 99 个百分位数: histogram_quantile(0.99, sum(rate(http_server_requests_seconds_bucket{exception="None", uri = "/your-uri"}[5m])) by (le))

For 95th percentile : histogram_quantile(0.95, sum(rate(http_server_requests_seconds_bucket{exception="None", uri = "/your-uri"}[5m])) by (le))对于第 95 个百分位数: histogram_quantile(0.95, sum(rate(http_server_requests_seconds_bucket{exception="None", uri = "/your-uri"}[5m])) by (le))

More on it: A nice snippet from reference: https://distilledcourses.com/blog/application-monitoring-with-micrometer-prometheus-grafana-and-cloudwatch更多关于它:参考的一个很好的片段: https ://distilledcourses.com/blog/application-monitoring-with-micrometer-prometheus-grafana-and-cloudwatch

The histogram is a collection of buckets (or counters), each maintaining the number of events observed that took up to duration specified by the le tag.直方图是桶(或计数器)的集合,每个桶都维护观察到的事件数,这些事件占用了 le 标签指定的持续时间。 Let's have a look at a part of the histogram as published by our demo application:让我们看一下演示应用程序发布的直方图的一部分:

http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="0.067108864",} 0.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="0.089478485",} 0.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="0.111848106",} 92382.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="0.134217727",} 99050.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="0.156587348",} 99703.0
...
...
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="0.984263336",} 99987.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="1.0",} 99987.0
http_server_requests_seconds_bucket{exception="None",method="GET",outcome="SUCCESS",status="200",uri="/demo",le="+Inf",} 100000.0

The second line in the listing above indicates there were no requests observed that took up to ~89ms (specified by the le tag).上面列表中的第二行表示没有观察到需要大约 89 毫秒(由 le 标签指定)的请求。 This is expected given the 100ms sleep time when processing requests.考虑到处理请求时的 100 毫秒睡眠时间,这是预期的。 Line #3 shows that 92,382 requests were observed whose duration took up to ~111ms.第 3 行显示,观察到 92,382 个请求,其持续时间长达约 111 毫秒。 Note that the histogram is cumulative and that the entire count of requests falls in the last bucket with no upper limit le="+Inf".请注意,直方图是累积的,并且整个请求计数落在最后一个桶中,没有上限 le="+Inf"。

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

相关问题 使用 spring java 的千分尺指标(没有 spring boot) - Micrometer metrics with spring java (NO spring boot) 在 Micrometer 中为动态指标设置描述的简洁方法是什么? - What is a clean way of setting description for dynamic metrics in Micrometer? 在 Java springboot 应用程序中使用千分尺收集 HikariCp 指标,方法是在 - HikariCp metrics collection using micrometer in Java springboot application by configuring it in 千分尺指标和 Application Insights java 代理 - 指标会累积,尽管它们不应该(或者我错过了什么) - Micrometer metrics & Application Insights java agent - Metrics accumulate although they shouldn't (or am I missing something) Springboot:千分尺指标未显示 - Springboot: micrometer metrics not showing up 在 Spring 微米中为端点启用指标 - Enable metrics for endpoints in Spring micrometer HashMap存储桶是什么类型 - What type is a HashMap bucket 使用Micrometer为InfluxDB指标设置通用标签 - Setting common tags with Micrometer for InfluxDB metrics 如何在运行的微服务中禁用/启用千分尺指标 - How to disable/enable Micrometer metrics in running microservice Prometheus端点中不提供使用Micrometer的自定义指标 - Custom metrics using Micrometer is not available in Prometheus endpoint
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM