Camunda Run 7.22 Metrics

Hi. I am trying to connect http metrics for Camunda Run running in docker.
The code of the application as a plugin:

package org.camunda.bpm.run.plugin.monitoring;

import io.micrometer.core.instrument.MeterRegistry;
import jakarta.ws.rs.ApplicationPath;
import lombok.RequiredArgsConstructor;
import org.camunda.bpm.spring.boot.starter.rest.CamundaJerseyResourceConfig;
import org.glassfish.jersey.micrometer.server.DefaultJerseyTagsProvider;
import org.glassfish.jersey.micrometer.server.MetricsApplicationEventListener;
import org.springframework.stereotype.Component;

@Component
@ApplicationPath("/engine-rest")
@RequiredArgsConstructor
public class JerseyConfig extends CamundaJerseyResourceConfig {

    private final MeterRegistry meterRegistry;

    @Override
    protected void registerAdditionalResources() {
        register(new MetricsApplicationEventListener(
                meterRegistry,
                new DefaultJerseyTagsProvider(),
                "camunda.http.server.requests",
                true
        ));
    }
}

dependencies

 <dependency>
            <groupId>org.camunda.bpm.springboot</groupId>
            <artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
            <version>${camunda.version}</version>
        </dependency>

        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>${micrometer.version}</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-micrometer</artifactId>
            <version>3.1.9</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-autoconfigure</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>${spring.version}</version>
        </dependency>

DockerFile:

FROM camunda/camunda-bpm-platform:run-7.22.0
COPY ./lib/camunda-metrics-test.jar /camunda/configuration/userlib/camunda-metrics.jar
COPY ./default.yml /camunda/configuration/default.yml

But I get the error that the Jersey bean already exists.


I wanted to inherit from the Camunda Bpm Run Rest Configuration and override method, but I didn’t find a dependency that could include it. Do you have any ideas?

This is a fascinating challenge! Integrating metrics with Camunda using Micrometer seems like a powerful way to enhance monitoring. I’m curious if anyone else has faced similar issues with Jersey configurations. What are some strategies you’ve used to avoid bean conflicts? Also, are there any best practices for setting up metrics in a Docker environment that you’ve found particularly helpful?

I decided to go the other way. Since the http metrics of spring MVC conflict with Jersey (i.e. the uri is displayed correctly for Jersey, but is duplicated for mvc where uri=“UNKNOWN”), I decided to simply filter them.
Here are the dependencies pom file with dependencies:

    <properties>
        <java.version>17</java.version>
        <camunda.version>7.22.0</camunda.version>
        <spring.version>3.3.3</spring.version>
        <micrometer.version>1.13.6</micrometer.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
            <version>${micrometer.version}</version>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-micrometer</artifactId>
            <version>3.1.9</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator-autoconfigure</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-actuator</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.camunda.bpm</groupId>
            <artifactId>camunda-engine</artifactId>
            <version>${camunda.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.34</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

Here is the fitration class:

package org.camunda.bpm.run.plugin.monitoring;

import io.micrometer.core.instrument.config.MeterFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MetricsConfig {

    @Bean
    public MeterFilter excludeAllExceptEngineRest() {
        return MeterFilter.deny(id -> {
            if (id.getName().startsWith("http.server.requests")) {
                return id.getTags().stream()
                        .noneMatch(tag -> tag.getKey().equals("uri") && tag.getValue().startsWith("/engine-rest/"));
            }
            return false;
        });
    }
}

Yaml settings for metrics:

management:
  endpoints:
    web:
      exposure:
        include: prometheus, metrics
  metrics:
    enable:
      jvm: true
      hikaricp: true
      process: true
      logback: false
      tomcat: false
      system: true
      jdbc: false
      http: true
    distribution:
      percentiles-histogram:
        http.server.requests: true
      percentiles:
        http.server.requests: 0.5, 0.9, 0.95, 0.99

I package everything in a jar file and put it as a plugin in the Docker image.
I use prometheus and Grafana for the display.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.