Reputation: 5144
Based on the Camel's metrics documentation, I'd like to meter 2 different timers within one route:
@Override
public void configure() {
from(
getMqttRouteConfiguration(
sourceId, mqttHost, mqttTopic, mqttPort, mqttProtocol, authenticated,
username, password, mqttVersion, maxReadRate, qualityOfService
)
)
.to("metrics:timer:simple.timer1?action=start") //here starts the first one
.to("log:camel.proxy?level=INFO&groupInterval=500000")
.to("metrics:counter:simple.counter")
.to(String.format("kafka:%s?brokers=%s", sourceId, kafkaBrokerUrls))
.to("metrics:timer:simple.timer1?action=stop") //here ends the first one
.to("metrics:timer:simple.timer2?action=start") //here starts the second one
.process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody(exchange.getIn().getBody(String.class));
exchange.getIn().setHeader("CamelCacheKey", sourceId);
exchange.getIn().setHeader("CamelCacheOperation", "Update");
}
})
.to(String.format("cache://%s?maxElementsInMemory=10&eternal=true", sourceId))
.to("metrics:timer:simple.timer2?action=stop") //here ends the second one
.routeId(sourceId);
}
i.e. take 2 timers from two different parts of route instead of the whole route statistics like
CamelRoutePolicy_seconds_count{camelContext="camel-1",failed="false",routeId="ESP_01.Handle_Movement",serviceName="MicrometerRoutePolicyService",} 137.0
CamelRoutePolicy_seconds_sum{camelContext="camel-1",failed="false",routeId="ESP_01.Handle_Movement",serviceName="MicrometerRoutePolicyService",} 1.200024598
as it is calculated automatically for the whole route. The set up of Micrometer format metrics output to /actuator/prometheus
for obtaining the CamelRoutePolicy_seconds_
is taken from this question: Send Apache Camel Actuator Metrics to Prometheus
However, my expectation was that the custome metrics metrics:timer:simple.timer2
, metrics:timer:simple.timer1
will be also here and shown among the CamelRoutePolicy_seconds_
But it is not there. What I should set up in order to get it too?
Upvotes: 1
Views: 3055
Reputation: 5144
So, the long story short: Apache Camel's Metrics component is not the same as Micrometer
I was needed the Micrometer. So, in all routes I had to replace metrics:
with micrometer:
and everything has worked. Please also consider that dependencies (looks like both are needed):
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-micrometer-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-micrometer</artifactId>
<version>${camel.version}</version>
</dependency>
Upvotes: 3