Java 向普罗米修斯发送数据

Java 向普罗米修斯发送数据,java,spring-boot,apache-camel,prometheus,Java,Spring Boot,Apache Camel,Prometheus,我正在尝试将致动器骆驼指标从/exactor/camelroutes(路由指标,如交换/交易数量)转发/添加到普罗米修斯致动器端点。有没有一种方法可以让我配置Camel将这些度量添加到PrometheusMeterRegistry中 我尝试补充: camel.component.metrics.metric-registry=io.micrometer.prometheus.PrometheusMeterRegistry 在我的application.properties中,根据此处的文档:

我正在尝试将致动器骆驼指标从
/exactor/camelroutes
(路由指标,如交换/交易数量)转发/添加到普罗米修斯致动器端点。有没有一种方法可以让我配置Camel将这些度量添加到PrometheusMeterRegistry中

我尝试补充:

camel.component.metrics.metric-registry=io.micrometer.prometheus.PrometheusMeterRegistry
在我的
application.properties
中,根据此处的文档:

但是在执行器/普罗米修斯中仍然没有显示任何与Apache Camel相关的内容

以下是我在Spring Boot 2.1.9和Apache Camel 2.24.2中使用的依赖项:


org.springframework.boot
弹簧靴起动器执行器
org.apache.camel
骆驼起动器
千分尺
普罗米修斯测微计

有一个
驼峰测微计启动器
依赖项,您应该使用它与测微计集成。然后,您可以使用该依赖关系中的测微计路由策略,让它监视您的所有路由。请参阅以下文档:

让骆驼路线指标在
/exactor/prometheus
端点工作

使用@claus ibsen评论中所述的骆驼测微计启动器


org.apache.camel
骆驼起动器
在属性文件中设置以下内容:

camel.component.metrics.metric-registry=prometheusMeterRegistry
然后添加并设置驼峰上下文以使用MillimorRouterPolicyFactory和MillimorMessageHistoryFactory。下面看到的代码位于配置类中:

@配置
公共类AppConfig{
@豆子
公共CamelContextConfiguration CamelContextConfiguration(){
返回新的CamelContextConfiguration(){
@凌驾
应用程序启动前的公共无效(CamelContext CamelContext){
camelContext.addRoutePolicyFactory(新的RoutePolicyFactory());
setMessageHistoryFactory(新的messageHistoryFactory());
}
@凌驾
应用程序启动后公共无效(CamelContext CamelContext){
}
};
}
}
您需要在路由中触发交换,以使度量显示在
/exactor/prometheus

以下是普罗米修斯可用的指标:

  • CamelMessage历史记录\u秒\u计数
  • CamelMessageHistory_seconds_max
  • CamelRoutePolicy_秒数_最大值
  • CamelRoutePolicy\u秒数\u计数
  • CamelRoutePolicy_seconds_sum

  • 您可以使用JMX Exporter jar for Prometheus从Camel的JMX获取更详细的指标。我想避免这种方法,因为这意味着我拥有的每个Camel Spring Boot应用程序将使用2个端口;1用于JMX指标,1用于致动器指标。

    我已经添加了这一点,但在
    /actutator/prometheus
    页面中出现驼峰指标时,我遇到了一个问题。我曾尝试将
    camel.component.milometer.metrics注册表设置为
    metricsRegistry
    io.milometer.prometheus.prometheus注册表
    prometheus注册表
    ,但仍然没有成功。我是否需要在配置类中定义一个bean,以使度量显示在Prometheus Actuator端点中?我尝试将其添加到我的配置类中,但
    /Actuator/Prometheus
    页面bacame为空:
    @bean(千分尺常量.metrics\u REGISTRY\u NAME)public Prometheus meterRegistry(){返回新的PrometheusMeterRegistry(PrometheusConfig.DEFAULT);}
    我尝试设置
    camel.component.milomer.metrics registry=prometheusMeterRegistry
    并使Prometheus执行器端点再次工作,但似乎没有添加任何与camel相关的内容。您还需要路由策略工厂让它监视camel路由添加我的配置类,但仍然没有更改:
    @Bean public CamelContextConfiguration contextConfiguration(){返回新的CamelContextConfiguration(){@Override public void beforeApplicationStart(CamelContext CamelContext){CamelContext.addRoutePolicyFactory(new MillimeterRoutePolicyFactory());CamelContext.setMessageHistoryFactory(新消息HistoryFactory();}@Override public void afterApplicationStart(CamelContext CamelContext){};}
    我也在尝试实现这一点,谢谢你的帖子,我能够看到你发布的上述指标。只是想知道,在你的实现中,这些是你唯一监控的骆驼指标吗?你能够实现你自己的PrometheusMeterRegistry bean吗?你能分享DimmomerRouterPolic的pom依赖性吗yFactory and MillimeterMessageHistoryFactory.@prashant.kr.mod它是
    org.apache.camel camel Millimeter