Current state: Under Discussion
Discussion thread: here
Messages stored in Kafka will expire and disappear silently based on retention time and size configuration. Consumers have no way to know they have missed messages.
I propose to expose a JMX metric after a message has been removed due to topic time/size retention settings, for a set of consumer groups specified on the topic configuration.
This could be implemented because the kafka brokers know the information needed for the task:
- offset of the message that has been removed.
- last offset consumed from a consumer group.
The compacted topics are out of scope, because when users chose compacted topics they are interested on the last value of they key, not on the intermediary states.
A new property at topic level should be created:
|Name||Description||Type||Default||Valid Values||Server default property||Importance|
|non.consumed.offsets.groups||comma separated list of consumer groups that will expose a metric with the number of messages that expired before being consumed||List||""||""||medium|
A new JMX metric should be created to be exposed by the broker:
|Metric / Attribute Name||Description||MBEAN NAME|
|non-consumed-total||Number of messages expired without being consumed by a consumer group, per topic and partition|
Currently the LogManager schedule the "kafka-delete-logs" thread, that will call the deleteLogs() method. Is possible to add into that method the metric to expose the number of offsets non consumed by a list of consumer groups.
The pseudo code starts on the line 19:
Compatibility, Deprecation, and Migration Plan
There is no impact on existing features.
Logging on broker side
To write logs on the broker to side to alert that messages have not been consumed has been rejected in favour of standard monitoring. Main reason is the big amount of data that could be generated.