如何使用Prometheus的JMX Exporter Java代理收集自定义指标 [英] How to use Prometheus' JMX exporter java agent to collect custom metrics

查看:645
本文介绍了如何使用Prometheus的JMX Exporter Java代理收集自定义指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Prometheus的JMX导出器来使用Prometheus收集自定义应用程序指标.我有一个打包到jar文件ApplicationToMonitor.jar中的应用程序-它公开了端口8989并声明了Prometheus指标,但没有公开Prometheus抓取的端点(根据我的阅读,Prometheus javaagent会负责).

I'd like to use Prometheus' JMX exporter to collect custom application metrics using Prometheus. I have an application that I've packaged into a jar file ApplicationToMonitor.jar-- it exposes port 8989 and declares Prometheus metrics, but doesn't expose an end-point for prometheus to scrape (from what I've read, the prometheus javaagent takes care of this).

我不确定configuration.yaml文件的外观.此外,为什么建议一个人使用shaded.io.prometheus库(并在默认注册表中注册新的度量变量)而不是常规的io.prometheus库,而不使用一个注册表?

I'm not sure what the configuration.yaml file should look like. Also, why is it recommended that one use the shaded.io.prometheus library (and register new metric variables under the default registry) as opposed to the regular io.prometheus library and not using a registry at all?

我引用的是 Prometheus JMX导出器文档,只是根本不理解上述组件.

I'm referencing the Prometheus JMX exporter documentation, just simply not understanding the aforementioned components.

推荐答案

您只会将JMX导出器用于不受您控制的公开JMX指标的代码.在这种情况下,您需要根据 https://github.com/prometheus/client_java#http. HTTPServer最简单.

You would only use the JMX exporter for code you don't control that's exposing JMX metrics. In this case you need to add some exposition per https://github.com/prometheus/client_java#http. The HTTPServer is simplest.

这篇关于如何使用Prometheus的JMX Exporter Java代理收集自定义指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆