The Kafka integration allows you to monitor your Apache Kafka cluster with the Atatus Infrastructure Agent. The agent talks to the brokers over the Kafka protocol, so you do not need JMX, Jolokia, or a metrics exporter on the brokers. Use this integration to:
  • Track cluster health: brokers, topics, partitions, and offline or under-replicated partitions.
  • Measure topic throughput as the number of messages written in each interval.
  • Watch consumer group lag per topic and per partition, so you know when a consumer falls behind.
  • See each consumer group’s state (Stable, Empty, Rebalancing, and so on) and its number of members.
  • Collect Kafka broker logs.
All metrics collected through this integration are treated as custom metrics.

Setup

No additional installation is required. The Kafka integration is bundled with the Atatus Infrastructure Agent. The agent only reads cluster metadata, offsets, and consumer group details. It never produces or consumes messages.

Permissions for clusters with ACLs

If your cluster uses ACLs, give the agent’s user Describe permission on the cluster, on the topics, and on the consumer groups you want to monitor. These permissions are read-only. The examples use a user named atatus:
Replace '*' with specific topic or group names to limit what the agent can see. Topics and groups the agent cannot describe are left out of the metrics.

Configuration

Metrics

Copy the Kafka example configuration file that ships with the agent:
Then add the following configuration to /etc/atatus-infra-agent/conf.d/kafka.d/kafka.yml. Each entry monitors one Kafka cluster:
Check these before you save:
  • hosts lists one or more bootstrap brokers of the cluster. The agent discovers the other brokers from them and reports the cluster once, however many brokers you list.
  • cluster_name is added to every metric as the kafka_cluster attribute. Set it when you monitor more than one cluster.
  • period is how often the agent collects metrics. The default is 30s.
Brokers reply with their advertised listener (advertised.listeners in the broker config), and the agent uses that address for every connection after the first one. That address must resolve and be reachable from the agent host. A broker running in Docker that advertises its container name, for example kafka:9092, needs a matching /etc/hosts entry on the agent host.

Authentication and TLS

For a cluster that uses SASL or TLS listeners, add the credentials and TLS settings to the same entry:
  • username and password are the SASL credentials. Leave both out for a PLAINTEXT listener.
  • kafka_options.sasl_mechanism is PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512. It defaults to PLAIN when a username is set.
  • tls.verification_mode is full, certificate, or none. Use none only for test brokers with self-signed certificates.

Filter topics and consumer groups

By default the agent reports every topic (except Kafka’s internal topics such as __consumer_offsets) and every consumer group. Use kafka_options to narrow this down:

Logs

Logs are configured in the same file as metrics. First, turn on log collection for the agent in /etc/atatus-infra-agent/atatus.yml:
Then add a logs section to /etc/atatus-infra-agent/conf.d/kafka.d/kafka.yml, pointing at your broker log files:

Verify Metrics

You can check that the brokers are reachable from the agent host with the tools that ship with Kafka:
A reachable broker prints its address and the API versions it supports. For a secured cluster, add --command-config with a client properties file that holds the same credentials as kafka.yml.

Restart the Agent

After configuration, restart the Atatus Infrastructure Agent:

Metrics

These are the metrics the integration collects from Kafka. Every metric also carries the host attribute, and kafka_cluster when cluster_name is set.

Troubleshooting

If no Kafka metrics appear, check the agent log at /var/log/atatus-infra-agent/agent.log for lines that start with kafka integration:
  • the broker advertises <address>; that address must resolve and be reachable from this host: the first broker answered, but its advertised listener cannot be reached from the agent host. Fix advertised.listeners on the broker, or make the address resolve on the agent host (for example with an /etc/hosts entry).
  • kafka_options.sasl_mechanism ... is not supported: set sasl_mechanism to PLAIN, SCRAM-SHA-256, or SCRAM-SHA-512.
  • password must be set when username is configured: add the SASL password, or remove username for a PLAINTEXT listener.
  • per-partition series over max_partition_contexts ... were not sent: the cluster has more partitions than max_partition_contexts. Totals are still complete. Raise the limit, or narrow topics and consumer_groups, to get every partition.
  • Lag is missing for a consumer group: the group has not committed offsets for that topic yet, or the agent’s user lacks Describe permission on the group or the topic.