이 콘텐츠는 선택한 언어로 제공되지 않습니다.

Chapter 6. Observability


6.1. Health & liveness checks

Health & liveness checks are supported via the MicroProfile Health extension. They can be configured via the Camel Health API or via Quarkus MicroProfile Health.

All configured checks are available on the standard MicroProfile Health endpoint URLs:

6.1.1. Health endpoint

Camel provides some out of the box liveness and readiness checks. To see this working, interrogate the /q/health/live and /q/health/ready endpoints on port 9000:

$ curl -s localhost:9000/q/health/live
Copy to Clipboard Toggle word wrap
$ curl -s localhost:9000/q/health/ready
Copy to Clipboard Toggle word wrap

The JSON output will contain a checks for verifying whether the CamelContext and each individual route is in the 'Started' state.

This example project contains a custom liveness check class CustomLivenessCheck and custom readiness check class CustomReadinessCheck which leverage the Camel health API. You’ll see these listed in the health JSON as 'custom-liveness-check' and 'custom-readiness-check'. On every 5th invocation of these checks, the health status of custom-liveness-check will be reported as DOWN.

You can also directly leverage MicroProfile Health APIs to create checks. Class CamelUptimeHealthCheck demonstrates how to register a readiness check.

6.2. Metrics

We provide MicroProfile Metrics for exposing metrics.

Some basic Camel metrics are provided for you out of the box, and these can be supplemented by configuring additional metrics in your routes.

Metrics are available on the standard Quarkus metrics endpoint:

6.3. Monitoring a Camel application

With monitoring of your applications, you can collect information about how your application behaves, such as metrics, health checks and distributed tracing.

Note

This section uses the Observability example listed in the Red Hat build of Quarkus examples, adding observability with micrometer.

Tip

Check the Camel Quarkus User guide for prerequisites and other general information.

6.3.1. Creating a project

  1. Start in the Development mode
  2. Run the maven compile command:

    $ mvn clean compile quarkus:dev
    Copy to Clipboard Toggle word wrap

    This compiles the project, starts the application and lets the Quarkus tooling watch for changes in your workspace.

    Any modifications in your project automatically take effect in the running application.

    Tip

    Refer to the Development mode section of Camel Quarkus User guide for more details.

6.3.2. Enabling metrics

To enable observability features in Camel Quarkus, you must add additional dependencies to the project’s pom.xml file. The most important ones are camel-quarkus-opentelemetry and quarkus-micrometer-registry-prometheus.

  1. Add the dependencies to your project pom.xml:

    <dependencies>
    
        ...
    
        <dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-opentelemetry</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkiverse.micrometer.registry</groupId>
            <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
        </dependency>
    
        ...
    
    </dependencies>
    Copy to Clipboard Toggle word wrap

    With these dependencies you benefit from both Camel Micrometer and Quarkus Micrometer.

6.3.3. Creating meters

You can create meters for custom metrics in multiple ways:

6.3.3.1. Using Camel micrometer component

With this method you use Routes.java.

.to("micrometer:counter:org.acme.observability.greeting-provider?tags=type=events,purpose=example")
Copy to Clipboard Toggle word wrap

Which will count each call to the platform-http:/greeting-provider endpoint.

6.3.3.2. Using CDI dependency injection

With this method you use CDI dependency injection of the MeterRegistry:

@Inject
MeterRegistry registry;
Copy to Clipboard Toggle word wrap

Then using it directly in a Camel Processor method to publish metrics:

void countGreeting(Exchange exchange) {
    registry.counter("org.acme.observability.greeting", "type", "events", "purpose", "example").increment();
}
Copy to Clipboard Toggle word wrap
from("platform-http:/greeting")
    .removeHeaders("*")
    .process(this::countGreeting)
Copy to Clipboard Toggle word wrap

This counts each call to the platform-http:/greeting endpoint.

6.3.3.3. Using Micrometer annotations

With this method you use Micrometer annotations, by defining a bean TimerCounter.java as follows:

@ApplicationScoped
@Named("timerCounter")
public class TimerCounter {

    @Counted(value = "org.acme.observability.timer-counter", extraTags = { "purpose", "example" })
    public void count() {
    }
}
Copy to Clipboard Toggle word wrap

It can then be invoked from Camel via the bean EIP (see TimerRoute.java):

.bean("timerCounter", "count")
Copy to Clipboard Toggle word wrap

It will increment the counter metric each time the Camel timer is fired.

6.3.3.4. Browsing metrics

Metrics are exposed on an HTTP endpoint at /q/metrics on port 9000.

Note

Note we are using a different port (9000) for the management endpoint then our application (8080) is listening on. This is configured in application.properties via quarkus.management.enabled = true. See the Quarkus management interface guide for more information.

To view all Camel metrics do:

$ curl -s localhost:9000/q/metrics
Copy to Clipboard Toggle word wrap

To view only our previously created metrics, use:

$ curl -s localhost:9000/q/metrics | grep -i 'purpose="example"'
Copy to Clipboard Toggle word wrap

and you should see 3 lines of different metrics (with the same value, as they are all triggered by the timer).

Note

Maybe you’ve noticed the Prometheus output format. If you would rather use the JSON format, please follow the Quarkus Micrometer management interface configuration guide.

6.3.4. Tracing

To be able to diagnose problems in Camel Quarkus applications, you can start tracing messages. We will use OpenTelemetry standard suited for cloud environments.

All you need is to add the dependencies camel-quarkus-opentelemetry and quarkus-micrometer-registry-prometheus to your project pom.xml:

<dependencies>

    ...

    <dependency>
        <groupId>org.apache.camel.quarkus</groupId>
        <artifactId>camel-quarkus-opentelemetry</artifactId>
    </dependency>
    <dependency>
        <groupId>io.quarkiverse.micrometer.registry</groupId>
        <artifactId>quarkus-micrometer-registry-prometheus</artifactId>
    </dependency>

    ...

</dependencies>
Copy to Clipboard Toggle word wrap

Then configure the OpenTelemetry exporter in application.properties:

# We are using a property placeholder to be able to test this example in convenient way in a cloud environment
quarkus.otel.exporter.otlp.traces.endpoint = http://${TELEMETRY_COLLECTOR_COLLECTOR_SERVICE_HOST:localhost}:4317
Copy to Clipboard Toggle word wrap
Note

For information about other OpenTelemetry exporters, refer to the Camel Quarkus OpenTelemetry extension documentation.

To view tracing events, start a tracing server. A simple way of doing this is with Docker Compose:

$ docker-compose up -d
Copy to Clipboard Toggle word wrap

With the server running, browse to http://localhost:16686. Then choose 'camel-quarkus-observability' from the 'Service' drop down and click the 'Find Traces' button.

The platform-http consumer route introduces a random delay to simulate latency, hence the overall time of each trace should be different. When viewing a trace, you should see a hierarchy of 6 spans showing the progression of the message exchange through each endpoint.

6.3.5. Packaging and running the application

Once you are done with developing you can package and run the application.

Tip

For more details about the JVM mode and Native mode, see the "Package and run" section of the Camel Quarkus User guide

6.3.5.1. JVM mode

$ mvn clean package
$ java -jar target/quarkus-app/quarkus-run.jar
...
[io.quarkus] (main) camel-quarkus-examples-... started in 1.163s. Listening on: http://0.0.0.0:8080
Copy to Clipboard Toggle word wrap

6.3.5.2. Native mode

Important

Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section of Camel Quarkus User guide.

To prepare a native executable using GraalVM, run the following command:

$ mvn clean package -Pnative
$ ./target/*-runner
...
[io.quarkus] (main) camel-quarkus-examples-... started in 0.013s. Listening on: http://0.0.0.0:8080
...
Copy to Clipboard Toggle word wrap
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동