简体   繁体   English

Prometheus端点中不提供使用Micrometer的自定义指标

[英]Custom metrics using Micrometer is not available in Prometheus endpoint

I'm using Micrometer in Java Spring Boot 1.5 application to scrape custom metrics for Prometheus. 我在Java Spring Boot 1.5应用程序中使用Micrometer来为Prometheus刮取自定义指标。

I'm using "guageCollectionSize" method to count the number of entries in a HashMap. 我正在使用“ guageCollectionSize”方法来计算HashMap中的条目数。 When I print the guage value, I'm getting the correct output as expected. 当我打印测量值时,我得到了预期的正确输出。 But the problem is that I'm not able to view the custom metric in /prometheus endpoint. 但是问题是我无法在/ prometheus端点中查看自定义指标。

Please find the code below 请在下面找到代码

private Map<String, String> _strings;
private MeterRegistry registry;
_strings = new ConcurrentHashMap<String, String>();
_strings.put("Test","Test");
_strings.put("Test2","Test");
registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);

registry.gaugeCollectionSize("strings_count", Tags.empty(),_strings.keySet());
System.out.println(registry.get("strings_count").gauge().value());

Can someone please help me to fix this issue? 有人可以帮我解决此问题吗?

As I told you on the GitHub issue which you created on the project repository, you're creating your own PrometheusMeterRegistry but you should use the auto-configured one. 正如我在项目存储库上创建的GitHub问题上告诉您的那样 ,您正在创建自己的PrometheusMeterRegistry但应使用自动配置的PrometheusMeterRegistry

I created a sample that uses the auto-configured one and added a test for it. 我创建了一个使用自动配置的示例 ,并为此添加了一个测试

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

相关问题 当我使用千分尺的PrometheusMeterRegistry时,度量标准没有出现在prometheus终点 - Metrics not appearing at prometheus endpoint when I'm using micrometer's PrometheusMeterRegistry 使用micrometer.io更改普罗米修斯终点 - Change prometheus endpoint using micrometer.io Prometheus 不在“/metrics”端点上显示来自本地主机服务的自定义指标 - Prometheus not displaying custom metrics from localhost service on `/metrics` endpoint jersey 应用程序中的千分尺 Prometheus 指标(非弹簧) - Micrometer Prometheus metrics in jersey application (Non spring) 如何使用 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 使用 Jax-Rs 将 Prometheus Metrics Endpoint 添加到 Java 应用程序 - Add Prometheus Metrics Endpoint to Java App Using Jax-Rs 执行器普罗米修斯的自定义指标 - Custom Metrics for Actuator Prometheus 普罗米修斯端点中缺少 Spring Boot Webclient 指标 - Spring Boot Webclient metrics missing in prometheus endpoint 为 Prometheus 公开指标端点的替代方法是什么? - What would be the alternative to expose metrics endpoint for Prometheus? 如何在默认端点/指标下覆盖普罗米修斯 - How to override prometheus by default endpoint /metrics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM