integration-docs
Loading

Kafka integration

Stack 9.0.0 Serverless Observability Serverless Security

Version 1.23.2 (View all)
Subscription level
What's this?
Basic
Level of support
What's this?
Elastic
Ingestion method(s) File, Jolokia

This integration collects logs and metrics from Kafka servers.

The log dataset is tested with logs from Kafka 0.9, 1.1.0 and 2.0.0.

The broker, consumergroup, partition datastreams are tested with Kafka 0.10.2.1, 1.1.0, 2.1.1, 2.2.2 and 3.6.0.

The broker, consumer, controller, jvm, log_manager, network, producer, raft, replica_manager, topic metricsets require Jolokia to fetch JMX metrics. Refer to the How do I deploy this integration? section below for more information.

To monitor a Kafka component (such as a broker, producer, or consumer) with Jolokia, you need to attach its JVM agent to the Java process.

  1. Download the Jolokia JVM-Agent from the official website.

  2. Attach the Agent via KAFKA_OPTS by setting the KAFKA_OPTS environment variable before starting your Kafka process.

For example, to launch a console producer with the Jolokia agent enabled:

# Set the KAFKA_OPTS variable to point to the agent JAR
export KAFKA_OPTS="-javaagent:/path/to/jolokia-jvm-agent.jar=port=8778,host=localhost"

# Start the Kafka producer script
./bin/kafka-console-producer.sh --topic test --broker-list kafka_host:9092
		

Make sure to replace /path/to/jolokia-jvm-agent.jar with the actual path to the agent you downloaded.

The port and host parameters specify where the Jolokia agent will be accessible.

The log dataset collects and parses logs from Kafka servers.

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The broker dataset collects JMX metrics from Kafka brokers using Jolokia.

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

Note that this dataset would be only available if Kafka is run in KRaft mode.

The raft dataset collects metrics related to Kafka's Raft consensus algorithm implementation (KRaft), which is used for metadata management in Kafka without requiring ZooKeeper. KRaft mode is available in Kafka 3.0.0 and later versions.

This dataset includes metrics such as:

  • Append and fetch records rates
  • Commit latency (average and maximum)
  • Current epoch, leader, and vote information
  • High watermark and log offset metrics
  • Node state and voter information
  • Poll idle ratio

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The controller dataset collects metrics related to the Kafka controller, which is responsible for managing broker states, partition assignments, and other administrative operations in the Kafka cluster.

This dataset includes metrics such as:

  • Controller event manager metrics (queue processing and wait times)
  • Cluster state metrics (active brokers, controllers, topics, and partitions)
  • Record management metrics (lag, offset, and timestamp information)
  • Error and health metrics (offline partitions, heartbeat timeouts, metadata errors)

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The replica_manager dataset collects metrics related to Kafka's replica management system, which is responsible for handling data replication across brokers in the Kafka cluster.

This dataset includes metrics such as:

  • ReplicaAlterLogDirsManager metrics (dead threads, failed partitions, lag, and fetch rates)
  • ReplicaFetcherManager metrics (dead threads, failed partitions, lag, and fetch rates)
  • In-Sync Replica (ISR) metrics (expansions, shrinks, and update failures)
  • Partition metrics (leader count, offline replicas, under-replicated partitions)
  • Reassignment and replication health metrics (reassigning partitions, under min ISR partition count)

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The jvm dataset collects metrics related to the Java Virtual Machine (JVM) running the Kafka broker, providing insights into the performance and health of the Java runtime environment.

This dataset includes metrics such as:

  • Runtime metrics (uptime, VM name, version, and vendor)
  • Memory metrics (heap and non-heap usage, memory pool statistics)
  • Threading metrics (thread counts, deadlocks, thread states)
  • Garbage collection metrics (collection counts and times)
  • Class loading metrics (loaded and unloaded class counts)
  • Buffer pool metrics (memory usage and capacity)
  • JIT compilation metrics (time spent in compilation)

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The log_manager dataset collects metrics related to Kafka's log management system, which is responsible for handling log segments, cleaning, and maintenance operations.

This dataset includes metrics such as:

  • Log cleaner metrics (buffer utilization, cleaning times, recopy percentages)
  • Cleaner manager metrics (dirty log percentages, uncleanable partitions)
  • Log directory metrics (offline directories, directory status)
  • Log flush statistics (flush rates and times)
  • Log recovery metrics (remaining logs and segments to recover)

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The network dataset collects metrics related to Kafka's network subsystem, providing insights into the broker's network performance, request handling, and socket server operations.

This dataset includes metrics such as:

  • Socket server metrics (memory pool usage, expired connections)
  • Network processor metrics (idle percentages, queue sizes)
  • Request metrics for different request types (processing times, queue times)
  • Throttle time metrics (how long requests are throttled)
  • Request and response size metrics
  • Request channel metrics (queue sizes and processing performance)

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The topic dataset collects metrics specific to Kafka topics and their partitions, providing insights into topic throughput, partition health, and log segment information.

This dataset includes metrics such as:

  • Topic-level metrics (bytes in/out per second, message rates, fetch request rates)
  • Partition metrics (in-sync replicas, under-replicated status, minimum ISR status)
  • Log metrics (offset information, segment counts, log sizes)

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The consumer dataset collects metrics specifically for monitoring the performance, throughput, and health of Kafka consumers. It provides key insights into how effectively consumers are processing data, their rate of interaction with brokers, and whether they are keeping up with message production.

This dataset includes metrics such as:

  • Consumption Rates: Metrics like bytes_consumed, records_consumed, and in.bytes_per_sec track the throughput of the consumer in terms of both the number of messages and the volume of data processed per second.
  • Consumer Lag: The max_lag metric is a critical indicator of consumer health, showing the maximum delay between the producer writing a message and the consumer reading it.
  • Fetch Performance: The fetch_rate provides visibility into how frequently the consumer is requesting new messages from the broker.

Usage

The Consumer dataset relies on Jolokia to fetch JMX metrics. Refer to the link for more information about Jolokia.

Note that the Jolokia agent is required to be deployed along with the JVM application. This can be achieved by using the KAFKA_OPTS environment variable when starting the Kafka consumer application (replace /opt/jolokia-jvm-1.5.0-agent.jar with your Jolokia agent location):

export KAFKA_OPTS=-javaagent:/opt/jolokia-jvm-1.5.0-agent.jar=port=<port>,host=<host>
./bin/kafka-console-consumer.sh --topic=test --bootstrap-server=<kafka_host>:<kafka_port>
		

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

The producer dataset gathers metrics focused on the performance, efficiency, and health of Kafka producers. This data is crucial for understanding message production rates, identifying potential bottlenecks, and ensuring reliable data ingestion into Kafka topics.

This dataset includes metrics such as:

  • Throughput and Rate Metrics: Fields like record_send_rate, out.bytes_per_sec, and request_rate measure the producer's output, providing a clear view of how much data is being sent per second.
  • Batching Performance: Metrics such as batch_size_avg, batch_size_max, and records_per_request offer insights into the effectiveness of batching, which is key for optimizing producer efficiency.
  • Health and Error Indicators: The record_error_rate and record_retry_rate are vital for monitoring the health of the producer, highlighting issues that could lead to data loss or delays.
  • Resource Utilization: Metrics like available_buffer_bytes and io_wait help track resource usage and identify performance constraints related to memory or I/O.
  • Data Characteristics: Fields such as record_size_avg and record_size_max provide information about the size of the records being sent.

Usage

The Producer dataset relies on Jolokia to fetch JMX metrics. Refer to the link for more information about Jolokia.

Note that the Jolokia agent is required to be deployed along with the JVM application. This can be achieved by using the KAFKA_OPTS environment variable when starting the Kafka producer application (replace /opt/jolokia-jvm-1.5.0-agent.jar with your Jolokia agent location):

export KAFKA_OPTS=-javaagent:/opt/jolokia-jvm-1.5.0-agent.jar=port=<port>,host=<host>
./bin/kafka-console-producer.sh --topic test --broker-list <kafka_host>:<kafka_port>
		

ECS Field Reference

Please refer to the following document for detailed information on ECS fields.

This integration includes one or more Kibana dashboards that visualizes the data collected by the integration. The screenshots below illustrate how the ingested data is displayed.