Hi everyone! I am facing a problem with logstash and elasticsearch output plugin. Basically i want to index couchdb changes. Using this config:
[CODE]
input {
couchdb_changes {
db => "database"
host => "localhost"
port => 5984
username => "username"
password => "password"
#initial_sequence => 0 #this is only required for the an initial indexing
}
}
filter {
mutate {
add_field => { "action" => "%{[@metadata][action]}" }
}
if [action] == 'delete' {
elasticsearch {
hosts => ["localhost:9200"]
query => "_id:%{[@metadata][_id]}"
fields => ["type", "$doctype"]
sort => ""
}
} else {
mutate {
add_field => { "type" => "%{[doc][$doctype]}" } #yes, my docs have a $doctype field to store the type
}
}
}
output {
elasticsearch {
action => "%{[@metadata][action]}"
doc_as_upsert => true
document_id => "%{[@metadata][_id]}"
#document_type => "%{[@metadata][$doctype]}" # it wont work, why?
hosts => ["localhost:9200"]
index => "my_index"
}
stdout { codec => rubydebug } #enable this option for debugging purpose
}
[/CODE]
Trying to create or update something in couchdb will always give me and "update" action, and the final response from logstash:
←[33mFailed action. {:status=>404, :action=>["update"....
....=>404, "error"=>{"type"=>"document_missing_exception", "reason"=>"[my_document_type][my_document_id]: document missing", "shard"=>"-1", "inde
x"=>"my_index"}}}, :level=>:warn}←[0m
It seems that its not able to create the index if it comes from an updated couchdb wich has not been previously stored in the elasticsearch index. If I prevoiusly manually create the index for the document, it works. I dont know if couchdb_changes uri common behaviour is to throw an "update" action even if it is creating data. Manually configuring action=>"create" in elasticsearch output, throws a bunch of errors, starting from "not been able to reach elasticsearch at localhost:9200".
Using last 2.2.0 for elastic and 2.2.2 for logstash, but facing the same problem with previous versions.
I know im missing something (too many things indeed). Only want to do complex searchs for couchdb data through elasticsearch. Dont know if i need ELK or only with logstash and elasticsearch is sufficient. Thanks in advance!