Skip to content

Conflict between legacy KafkaListenerMetrics and Observation-based metrics (spring.kafka.listener_seconds tag mismatch) #4104

@Wolroys

Description

@Wolroys

Description:
In Spring Boot 3.3.x with Spring Kafka 3.3.x, enabling both Actuator metrics and Micrometer Observation causes a Prometheus registration conflict:

Prometheus requires that all meters with the same name have the same set of tag keys.
There is already an existing meter named 'spring.kafka.listener_seconds' containing tag keys [exception, name, result].
The meter you are attempting to register has keys [error, messaging.kafka.consumer.group, messaging.operation, messaging.system, spring.kafka.listener.id].

Steps to reproduce:

Use Spring Boot 3.3.10, Spring Kafka 3.3.10, Actuator, Micrometer, Prometheus.

Enable observation:

spring:
kafka:
listener:
observation-enabled: true

Do not disable Actuator’s default metrics (KafkaMetricsAutoConfiguration).

Run application with at least one @KafkaListener.

Actual result:
Prometheus rejects metric registration due to conflicting tag sets for the same name spring.kafka.listener_seconds.

Expected result:
Observation metrics and legacy metrics should not register under the same metric name. Either:

Observation should use a distinct metric name, or

The framework should automatically suppress legacy KafkaListenerMetrics when observation is enabled.

Environment:

Spring Boot: 3.3.10

Spring Kafka: 3.3.10

Micrometer: 1.13.x

Prometheus Meter Registry

Request:
Provide automatic suppression or name separation for legacy KafkaListenerMetrics when observation-enabled=true, to prevent Prometheus conflicts without manual exclusion.

I've been trying to turn off setMicrometerEnabled through kafkaConfiguration, but it actually hasn't worked

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions