简体   繁体   English

如何一次查询所有/执行器/指标?

[英]How to query all /actuator/metrics at once?

I'm using the Spring boot actuator as an internal API that is used by another API to monitor the Spring Boot application. 我使用Spring启动执行器作为内部API,另一个API使用它来监视Spring Boot应用程序。

The problem is that you have to query each and every property. 问题是你必须查询每个属性。 ie /actuator/metrics/jvm.memory.used /actuator/metrics/jvm.memory.used

So for every GET request, I have to make multiple requests (as many as there are metrics). 因此,对于每个GET请求,我必须发出多个请求(与指标一样多)。

Is it possible to query all of them at once? 是否可以一次查询所有这些?

You don't have an api given by spring boot out of the box, but you can make it very easly if you want to. 你没有开箱即用的弹簧开关api,但如果你愿意,你可以很容易地做到。 You need to use the endpoint MetricsEndpoint which is used by the framework when querying the /metrics apis. 您需要使用在查询/metrics apis时框架使用的端点MetricsEndpoint

You need to @Autowire it in your service and afterwards you can use it get the names of all metrics by using the method listNames() . 您需要在服务中@Autowire ,然后您可以使用方法listNames()获取所有指标的名称。 Starting from the list of provided names you can query the detail for each metric at a time. 从提供的名称列表开始,您可以一次查询每个指标的详细信息。

Here you have the reference page. 这里有参考页面。

If you use Prometheus it will expose new /actuator/prometheus endpoint which will list all the metrics at once. 如果您使用Prometheus ,它将显示新的/actuator/prometheus端点,它将立即列出所有指标。 See this tutorial for examples : 有关示例,请参阅本教程

# HELP jvm_buffer_memory_used_bytes An estimate of the memory that the Java virtual machine is using for this buffer pool
# TYPE jvm_buffer_memory_used_bytes gauge
jvm_buffer_memory_used_bytes{id="direct",} 81920.0
jvm_buffer_memory_used_bytes{id="mapped",} 0.0
# HELP jvm_threads_live The current number of live threads including both daemon and non-daemon threads
# TYPE jvm_threads_live gauge
jvm_threads_live 23.0
# HELP tomcat_global_received_bytes_total  
# TYPE tomcat_global_received_bytes_total counter
tomcat_global_received_bytes_total{name="http-nio-8080",} 0.0
...

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

相关问题 如何过滤Spring Boot执行器指标? - How to filter Spring boot actuator metrics? 执行器普罗米修斯的自定义指标 - Custom Metrics for Actuator Prometheus Spring Boot 2执行器指标 - Spring boot 2 actuator metrics 如何在 SpringBoot 执行器中按客户端名称过滤 Web 客户端指标? - How to filter out Web Client metrics by client name in SpringBoot actuator? 如何根据执行器指标的指标名称配置附加标签 - How to configure additional tags depending on metric name for actuator metrics Spring Boot Actuator:如何在自定义 HealthIndicator 中获取指标正常运行时间? - Spring Boot Actuator: How to get metrics uptime inside a custom HealthIndicator? 获取 Spring 执行器的“健康”指标 - Obtain Spring actuator 'health' metrics 如何使用 Micrometer 格式和 /actuator/prometheus 将 Apache Camel 指标(如 metrics:timer:simple.timer)输出到 Prometheus - How to output Apache Camel metrics like metrics:timer:simple.timer to Prometheus using Micrometer format with /actuator/prometheus 如何在代码中获取 spring-boot-actuator 指标数据? - How can I get the spring-boot-actuator metrics data in code? 没有@EnableAutoConfiguration 的 Spring 执行器指标存在问题 - Problem with Spring Actuator metrics without @EnableAutoConfiguration
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM