将Apache Camel执行器指标发送给Prometheus [英] Send Apache Camel Actuator Metrics to Prometheus

查看:112
本文介绍了将Apache Camel执行器指标发送给Prometheus的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将来自/actuator/camelroutes 的执行器骆驼度量(路由度量,如交换/交易次数)转发/添加到Prometheus执行器端点.我可以配置骆驼以将这些指标添加到PrometheusMeterRegistry吗?

I am trying to forward/add the Actuator Camel metrics from /actuator/camelroutes (route metrics like number of exchanges/transactions) to the Prometheus Actuator endpoint. Is there a way for me to configure Camel to add those metrics to the PrometheusMeterRegistry?

我尝试添加:

camel.component.metrics.metric-registry=io.micrometer.prometheus.PrometheusMeterRegistry

根据此处的文档在 application.properties

:但是在 actuator/prometheus

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

Here are the dependencies I am using with Spring Boot 2.1.9 and Apache Camel 2.24.2:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
        <groupId>org.apache.camel</groupId>
            <artifactId>camel-metrics-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>

推荐答案

使用在/actuator/prometheus 端点中工作的骆驼路线度量标准.

Got the Camel Routes metrics working in the /actuator/prometheus endpoint.

使用@ claus-ibsen的评论所述的 camel-micrometer-starter 依赖项.

Use the camel-micrometer-starter dependency as stated by @claus-ibsen 's comment.

        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-metrics-starter</artifactId>
        </dependency>

在属性文件中设置以下内容:

Set the following in your properties file:

camel.component.metrics.metric-registry=prometheusMeterRegistry

然后添加设置骆驼上下文以使用MicrometerRouterPolicyFactory和MicrometerMessageHistoryFactory.下面显示的代码是Configuration类中的位置:

Then add set the Camel Context to use the MicrometerRouterPolicyFactory and MicrometerMessageHistoryFactory. Code seen below is places in a Configuration class:

@Configuration
public class AppConfig {

    @Bean
    public CamelContextConfiguration camelContextConfiguration() {

        return new CamelContextConfiguration() {
            @Override
            public void beforeApplicationStart(CamelContext camelContext) {
                camelContext.addRoutePolicyFactory(new MicrometerRoutePolicyFactory());
                camelContext.setMessageHistoryFactory(new MicrometerMessageHistoryFactory());
            }

            @Override
            public void afterApplicationStart(CamelContext camelContext) {

            }
        };
    }

}

您需要触发路由交换,以使指标显示在/actuator/prometheus 中.

You need to trigger an exchange in a route for the metrics to appear in /actuator/prometheus.

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

Here are the metrics made available to Prometheus:

  1. CamelMessageHistory_seconds_count
  2. CamelMessageHistory_seconds_max
  3. CamelRoutePolicy_seconds_max
  4. CamelRoutePolicy_seconds_count
  5. CamelRoutePolicy_seconds_sum

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

You can use the JMX Exporter jar for Prometheus to get the more detailed metrics from the JMX of Camel. I wanted to avoid this approach as it would mean that for each Camel Spring Boot App I have would use 2 ports; 1 for the JMX Metrics and 1 for the Actuator Metrics.

这篇关于将Apache Camel执行器指标发送给Prometheus的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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