Send Apache Camel Actuator Metrics to Prometheus(将 Apache Camel 执行器指标发送到 Prometheus)
问题描述
我正在尝试将 Actuator Camel 指标从 /actuator/camelroutes
(路由指标,如交换/交易数量)转发/添加到 Prometheus Actuator 端点.有没有办法让我配置 Camel 以将这些指标添加到 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
中:https://camel.apache.org/components/latest/metrics-component.html
in my application.properties
according to the documentation here: https://camel.apache.org/components/latest/metrics-component.html
但 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>
推荐答案
让 Camel Routes 指标在 /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
然后添加设置 Camel 上下文以使用 MicrometerRouterPolicyFactory 和 MicrometerMessageHistoryFactory.下面看到的代码是配置类中的位置:
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
.
以下是 Prometheus 可用的指标:
Here are the metrics made available to Prometheus:
- CamelMessageHistory_seconds_count
- CamelMessageHistory_seconds_max
- CamelRoutePolicy_seconds_max
- CamelRoutePolicy_seconds_count
- CamelRoutePolicy_seconds_sum
您可以使用 Prometheus 的 JMX Exporter jar 从 Camel 的 JMX 中获取更详细的指标.我想避免这种方法,因为这意味着对于我拥有的每个 Camel Spring Boot 应用程序将使用 2 个端口;1 个用于 JMX 指标,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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 Apache Camel 执行器指标发送到 Prometheus


- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01