问题
How can I get alerted when there is a message rate in some topic higher or lower than usual?
回答1:
Kafka emits tons of metrics that allow to monitor its usage and health. This includes metrics for incoming message rate, see the Monitoring section in the docs.
Your use case is typically achieved with a tool that handles metrics and is able to fire alerts based on user defined queries.
For example, Prometheus handles that very well. You need to set it up so metrics from Kafka are forwarded to Prometheus (using https://github.com/prometheus/jmx_exporter). As it's a very common use case, you'll find hundreds of articles online that describe how to set that up. The JMX exporter has sample configs for the Kafka JMX patterns, as well.
Once the metrics are in Prometheus you can aggregate them across brokers and set up Alerts.
来源:https://stackoverflow.com/questions/54168657/how-to-monitor-messages-rate-in-kafka-topics