Dynamic elasticsearch index_type using logstash -
i working on storing data on elasticsearch using logstash rabbitmq server.
my logstash command looks like
logstash -e 'input{ rabbitmq { exchange => "redwine_log" key => "info.redwine" host => "localhost" durable => true user => "guest" password => "guest" } } output { elasticsearch { host => "localhost" index => "redwine" } } filter { json { source => "message" remove_field => [ "message" ] } }'
but needed logstash put data different types in elasticsearch cluster. meant type is:
"hits": { "total": 3, "max_score": 1, "hits": [ { "_index": "logstash-2014.11.19", "_type": "logs", "_id": "zeea8hboss-qwh67q1kcaw", "_score": 1, "_source": { "context": [], "level": 200, "level_name": "info",
this part of search result, can see logstash defualt creates type named "logs" (_type : "logs"). in project needed type dynamic , should created based on input data. example: input data looks like
{ "data":"some data", "type": "type_1" }
and need logstash create new type in elasticsearch name "type_1"..
i tried using grok..but couldnt able specifc requirment.
its worked me in way
elasticsearch { host => "localhost" index_type => "%{type}" }
Comments
Post a Comment