Created
January 13, 2018 16:26
-
-
Save kpietralik/08599f5557cad9d1825bf28623e62d80 to your computer and use it in GitHub Desktop.
Logstash configuration file for ingesting Stack Exchange events data from Kafka topic to Elasticsearch index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
kafka { | |
bootstrap_servers => "KAFKA_ADDRESS_AND_PORT" | |
group_id => "logstash" | |
topics => ["posts"] | |
codec => "json" | |
type => "posts" | |
consumer_threads => 2 | |
} | |
} | |
filter { | |
mutate { | |
add_field => { "EventDate" => "%{@timestamp}" } | |
} | |
} | |
output { | |
if [type] == "posts" { | |
if [answer_id] { | |
elasticsearch { | |
hosts => ["ES_ADDRESS_AND_PORT"] | |
manage_template => false | |
index => "posts" | |
document_type => "answer" | |
document_id => "%{answer_id}" | |
} | |
} else if [comment_id] { | |
elasticsearch { | |
hosts => ["ES_ADDRESS_AND_PORT"] | |
manage_template => false | |
index => "posts" | |
document_type => "comment" | |
document_id => "%{comment_id}" | |
} | |
} else if [question_id] { | |
elasticsearch { | |
hosts => ["ES_ADDRESS_AND_PORT"] | |
manage_template => false | |
index => "posts" | |
document_type => "question" | |
document_id => "%{question_id}" | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment