“Kafka™ is used for building real-time data pipelines and streaming apps. It is horizontally scalable, fault-tolerant, wicked fast, and runs in production in thousands of companies.” - Official Kafka Site
Kafka is essentially a powerful, fast message brokering system used to transfer a payload/message from many applications to many applications. This is a Java based application that exposes metrics through mBeans.
There are four main components to Kafka:
The Kafka Integration uses Datadog’s JMXFetch application to pull metrics, just like our other Java based applications such as Cassandra, JMX, Tomcat, etc. This pulls metrics through the use of mBeans, where the engineering team has included a list of commonly used mBeans in the Kafka.yaml file. This can be extended with any other beans the user would like, or if your version of Kafka supports additional metrics.
The Kafka_Consumer Integration collects metrics like our standard Python based checks. This uses an internal Zookeeper API. Zookeeper is an Apache application that is responsible for managing the configuration for the cluster of nodes known as the Kafka broker. (In version 0.9 of Kafka things are a bit different, Zookeeper is no longer required, see the Troubleshooting section for more information). This check picks up only three metrics, and these do not come from JMXFetch.
This issue only applies if you are running version <5.20 of the Datadog Agent. In older versions of Kafka, consumer offsets were stored in Zookeper exclusively. The initial Kafka_consumer Agent Check was written when this limitation was in place. Due to this, you cannot get the
kafka.consumer_lag metric if your offsets are stored in Kafka and you are using an older version of the Agent. Upgrade the Agent to the latest version to see these metrics.
You might see the following error for the Datadog-Kafka integration:
instance #kafka-localhost-<PORT_NUM> [ERROR]: 'Cannot connect to instance localhost:<PORT_NUM>. java.io.IOException: Failed to retrieve RMIServer stub
This error means the Datadog Agent is unable to connect to the Kafka instance to retrieve metrics from the exposed mBeans over the RMI protocol. The error can be resolved by including the following Java Virtual Machine (JVM) arguments when starting the Kafka instance (required for all separate Java instances - producer, consumer, and broker).
By default Datadog only collects broker based metrics.
For Java based producers and consumers, add the following to the
conf.yaml and update the settings as necessary. See the sample kafka.d/conf.yaml for all available configuration options.
- host: remotehost port: 9998 # Producer tags: - kafka: producer0 - host: remotehost port: 9997 # Consumer tags: - kafka: consumer0
Note: This method does not work if you are using custom producer and consumer clients written in other languages or not exposing mBeans. To submit your metrics from your code, use DogStatsD.
This issue is specifically for the Kafka Consumer Agent check. If you specify a partition in
kafka_consumer.d/conf.yaml that doesn’t exist in your environment, you see the following error:
instance - #0 [Error]: ''
To remedy, specify the correct partition for your topic. This correlates to this line:
# <TOPIC_NAME_1>: [0, 1, 4, 12]
The number of partition contexts collection is limited to 200. If you require more contexts, contact Datadog support.