Skip to content

KAFKA-20453: Add nodeId and listenerType tags to SocketServer metrics#22074

Closed
ChoMinGi wants to merge 1 commit into
apache:trunkfrom
ChoMinGi:kafka-20453-socketserver-metrics-tags
Closed

KAFKA-20453: Add nodeId and listenerType tags to SocketServer metrics#22074
ChoMinGi wants to merge 1 commit into
apache:trunkfrom
ChoMinGi:kafka-20453-socketserver-metrics-tags

Conversation

@ChoMinGi
Copy link
Copy Markdown
Contributor

@ChoMinGi ChoMinGi commented Apr 16, 2026

Add nodeId and listenerType tags to the four SocketServer gauge metrics(NetworkProcessorAvgIdlePercent, MemoryPoolAvailable, MemoryPoolUsed, ExpiredConnectionsKilledCount) so that each SocketServer instance registers unique metrics in the singleton Yammer registry.

In Combined KRaft mode, two SocketServer instances share the same JVM.
Without distinguishing tags, newGauge() returns the existing gauge from the first instance, causing metrics to always reflect the controller's values.

Also adds metric cleanup in shutdown() and replaces the reflection-based SocketServerMemoryPoolTest with a metric-based lookup.

Note that this changes JMX MBean names by appending the new tags.
I'm aware that KAFKA-19606 / KIP-1207 addressed a similar Combined KRaft metric issue for RequestHandlerAvgIdlePercent.
Please let me know if a KIP is needed for this change as well, or if an alternative approach (e.g. role-prefixed metric names) would be preferred.

Add nodeId and listenerType tags to the four SocketServer gauge metrics
(NetworkProcessorAvgIdlePercent, MemoryPoolAvailable, MemoryPoolUsed,
ExpiredConnectionsKilledCount) so that each SocketServer instance
registers uniquely-named metrics in the singleton Yammer registry.

- Add metric cleanup in SocketServer.shutdown()
- Replace reflection-based test with metric-based lookup in
  SocketServerMemoryPoolTest
- Add unit tests verifying metric tags and shutdown cleanup
- Update monitoring documentation with new MBean name format

https://issues.apache.org/jira/browse/KAFKA-20453
@github-actions github-actions Bot added triage PRs from the community core Kafka Broker clients small Small PRs labels Apr 16, 2026
@ChoMinGi ChoMinGi closed this Apr 16, 2026
@ChoMinGi
Copy link
Copy Markdown
Contributor Author

ChoMinGi commented Apr 16, 2026

Closing — this adds tags to Yammer MBean names which is a breaking change for monitoring setups.

KIP-1207 solved the same root cause (Combined KRaft metric collision) for RequestHandlerAvgIdlePercent by adding separate Broker/Controller-prefixed metrics without touching existing MBean names.
That approach seems more appropriate here too.

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

Labels

clients core Kafka Broker small Small PRs triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant