Skip to content

Instantly share code, notes, and snippets.

@talevy
Last active September 28, 2015 16:35
Show Gist options
  • Save talevy/6bf52a06b0c4a45c988a to your computer and use it in GitHub Desktop.
Save talevy/6bf52a06b0c4a45c988a to your computer and use it in GitHub Desktop.
Custom Partitioner in Logstash Kafka Output Plugin

Running Logstash Output Kafka With Custom Partitioner

checkout example round-robin partitioner and build jar

$ git clone git@github.com:talevy/kafka-round-robin-partitioner.git
$ cd kafka-round-robin-partitioner
$ ./gradlew fatJar

set java classpath env variable so logstash knows where to find the partitioner class

export CLASSPATH="$CLASSPATH:/path/to/kafka-round-robin-partitioner-all-1.0.0-SNAPSHOT.jar"

create kafka topic

$ bin/kafka-topics.sh  --create --topic roundrobin --partitions 4 --zookeeper localhost:2181 --replication-factor 1

run logstash with kafkaroundrobin-logstash.conf

$ bin/logstash -f kafkaroundrobin-logstash.conf

You should now see that the logs were are spread across the partitions

input {
generator {
count => 400
message => "round robin"
}
}
output {
kafka {
topic_id => "roundrobin"
partitioner_class => "org.logstash.kafka.partitioner.RoundRobinPartitioner"
}
}
@laule75
Copy link

laule75 commented Sep 28, 2015

Hello,

I don't see any code on this Git ?
Is it normal?

regards

Lau

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment