Error with config file

The config file like:

input {
http {
port => 20020
}

filter {
mutate {
rename => ["shortHostname", "hostname" ]
}
}

output {
if [usageReports][level] == "top" {
elasticsearch {
action => "update"
doc_as_upsert => true
hosts => ["localhost:9200", "192.168.2.212:9200", "192.168.2.213:9200"]
index => "hbovideo-%{+yyyy.MM.dd}"
document_id => "hbouser-%{[usageReports][userID]}"
document_type => "test_data"
}
} else if [usageReports][level] == "second" {
elasticsearch {
action => "update"
doc_as_upsert => true
hosts => ["localhost:9200", "192.168.2.212:9200", "192.168.2.213:9200"]
index => "hbovideo-%{+yyyy.MM.dd}"
document_id => "hbound-%{[usageReports][uniqueID]}"
document_type => "test_data"
}
} else {
elasticsearch {
hosts => ["localhost:9200", "192.168.2.212:9200", "192.168.2.213:9200"]
index => "hbovideo-%{+yyyy.MM.dd}"
document_type => "test_data"
}
}
}

For my troubleshooting, I am sure that the filter is the root cause, as I can perfect run with this configuration after remove filter part. But why? Is there any wrong with filter configuration?

I even tried remove everything inside fileter, like filter {}, it also went error.

this is the error

[ERROR] 2019-01-09 04:45:06.485 [Converge PipelineAction::Create] agent - Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, => at line 7, column 8 (byte 61) after input {\n http {\n port => 20020\n}\n\noutput {\n if ", :backtrace=>["/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:41:in compile_imperative'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:49:incompile_graph'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:11:in block in compile_sources'", "org/jruby/RubyArray.java:2486:inmap'", "/usr/share/logstash/logstash-core/lib/logstash/compiler.rb:10:in compile_sources'", "org/logstash/execution/AbstractPipelineExt.java:149:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:22:in initialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:90:ininitialize'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:42:in block in execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:92:inblock in exclusive'", "org/jruby/ext/thread/Mutex.java:148:in synchronize'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:92:inexclusive'", "/usr/share/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:38:in execute'", "/usr/share/logstash/logstash-core/lib/logstash/agent.rb:317:inblock in converge_state'"]}

Found input part missing a "}" at the end.........Can run now..

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