Skip to content

Monitor Kafka Streams application state out of the box #6079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pszymczyk opened this issue Apr 3, 2025 · 0 comments
Open

Monitor Kafka Streams application state out of the box #6079

pszymczyk opened this issue Apr 3, 2025 · 0 comments

Comments

@pszymczyk
Copy link

pszymczyk commented Apr 3, 2025

Feature request

I would like to monitor my Kafka Streams application state without without extra programming effort.

Rationale
Monitoring Kafka Streams application state is one of the basis metrics for operating Kafka Streams applications. When application is going to Re-Balancing state too often or stuck in Error state this is what really matters in Kafka Streams observability.

Additional context

Kafka Streams is by default reporting application state on top level client metrics. Library is reporting enum values:

Image

Because of reported value is not numeric, Micrometer is filtering this metric out in KafkaMetrics meter binder.

Image

Proposed solution
As every Kafka Stream state has also standard numeric representation we can translate enum -> double and report Kafka Streams application state out of the box. We can extend present KafkaMetrics meter binder implementation by adding there if statement for state metric and register gauge:

return stateMetric -> {
            KafkaStreams.State state = (KafkaStreams.State) stateMetric.metricValue();

            return switch (state) {
                case CREATED -> 0;
                case RUNNING -> 2;
                case REBALANCING -> 1;
                case PENDING_SHUTDOWN -> 3;
                case NOT_RUNNING -> 4;
                case ERROR -> 5;
                default -> -1;
            };
        };

Additional resources

When you find this feature useful I would like to provide an implementation implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant