2020-08-12 04:10:41 +08:00
# Kafka Consumer Legacy Input Plugin
2017-06-08 09:22:28 +08:00
2021-11-17 06:11:24 +08:00
### Deprecated in version 1.4. Please use [Kafka Consumer input plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/kafka_consumer).
2017-06-08 09:22:28 +08:00
The [Kafka ](http://kafka.apache.org/ ) consumer plugin polls a specified Kafka
topic and adds messages to InfluxDB. The plugin assumes messages follow the
line protocol. [Consumer Group ](http://godoc.org/github.com/wvanbergen/kafka/consumergroup )
is used to talk to the Kafka cluster so multiple instances of telegraf can read
from the same topic in parallel.
## Configuration
```toml
# Read metrics from Kafka topic(s)
[[inputs.kafka_consumer]]
## topic(s) to consume
topics = ["telegraf"]
2019-09-24 06:39:50 +08:00
2017-06-08 09:22:28 +08:00
## an array of Zookeeper connection strings
zookeeper_peers = ["localhost:2181"]
2019-09-24 06:39:50 +08:00
2017-06-08 09:22:28 +08:00
## Zookeeper Chroot
zookeeper_chroot = ""
2019-09-24 06:39:50 +08:00
2017-06-08 09:22:28 +08:00
## the name of the consumer group
consumer_group = "telegraf_metrics_consumers"
2019-09-24 06:39:50 +08:00
2017-06-08 09:22:28 +08:00
## Offset (must be either "oldest" or "newest")
offset = "oldest"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
## Maximum length of a message to consume, in bytes (default 0/unlimited);
## larger messages are dropped
max_message_len = 65536
```
## Testing
Running integration tests requires running Zookeeper & Kafka. See Makefile
for kafka container command.