Camel Quarkus 0.3.0 includes support for adding observability capabilities such as application metrics, health checks and distributed tracing. This post gives a brief explanation of how to configure and use these features.
Camel Quarkus provides an extension which builds on top of Quarkus metrics so that Camel applications can produce metrics and have them processed by tools such as Prometheus.
To start working with metrics, add the camel-quarkus-microprofile-metrics extension
NOTE: There’s no version specified. It’s assumed that the project parent is camel-quarkus-bom. Refer to the Camel Quarkus getting started guide.
When the extension is included, it automatically begins to collect Camel related metrics. Such as:
The number of completed, failed or inflight exchanges
The mean, minimum and maximum processing processing times for exchanges through each route
Each metric is tagged with the name of the Camel context and where appropriate, the Camel route id.
You can review the generated metrics by executing curl -H"Accept: application/json" localhost:8080/metrics/application. To view the output in the OpenMetrics format, remove the
-H"Accept: application/json" argument. The example output should look something like this.
You can generate your own custom metrics by configuring microprofile-metrics endpoints in your Camel routes. For example, to increment a counter metric every 10 seconds:
Alternatively, you can leverage the MicroProfile metrics API in your code. Refer to the Quarkus metrics documentation for more information about that.
Support for health checks with Camel Quarkus is provided by the camel-quarkus-microprofile-health extension. It builds on top of Quarkus health.
To start working with health checks add the camel-quarkus-microprofile-health extension
Provided health checks
Camel provides some simple liveness and readiness checks out of the box. To see these in action, execute curl localhost:8080/health/live and curl localhost:8080/health/ready. You should see an output similar to below.
The first status field indicates that the overall liveness or readiness of the application is “UP”. The checks field contains a summary of all of the configured liveness or readiness checks.
In this case there is a check named ‘camel’ which verifies whether the Camel context status is ‘Started’. In this case this condition is true so the health check status is reported as “UP”. You’d see it as “DOWN” if the context status was any other value.
Custom health checks
You can write your application health checks using the Camel Health API. There are two convenience classes that can be extended: