Is it possible to use if else conditional within elastic serach output plugin?

Hi
Can following configuration :
output {
if([type] == "A"){
elasticsearch{
hosts => ["localhost:9200"]
index => "aaa"
document_type => "_doc"
document_id => "11"
http_compression => true
manage_template => true
template => "logstash-6.4.2/config/pipelines/Templates"
template_name => "errt"
}
}else if([type]=="B"){
elasticsearch{
hosts => ["localhost:9200"]
index => "aaa"
document_type => "_doc"
document_id => "11"
action => "update"
script_lang => "painless"
script_type => "inline"
script => ''
}
}else{
stdout { codec => rubydebug }
}
}

Be written as :
output {
elasticsearch{
hosts => ["localhost:9200"]
index => "aaa"
document_type => "_doc"
document_id => "11"
http_compression => true
if([type] == "A"){
manage_template => true
template => "logstash-6.4.2/config/pipelines/Templates"
template_name => "errt"
}else if([type]=="B"){
action => "update"
script_lang => "painless"
script_type => "inline"
script => ' '
} else{
stdout { codec => rubydebug }
}

	}

}

Yes: https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals

It is not allowing if else conditionals inside elasticsearch output plugin. Giving execption on if block line number.

You can not use conditional within any filter block.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.