Hi People,
I try to get some conditional splitting in logstash conf working, and missing something maybe...
I use this config:
input {
tcp {
port => 5001
type => syslog
}
udp {
port => 5001
type => syslog
}
}
filter {
if "Drop:" in [message] { grok { match => { "message" => "(?<\d+>)(?\w+\s\d+\s\d+.\d+.\d+)%{SPACE}%{HOSTNAME}%{SPACE}(?\d(.?)(:))%{SPACE}%{SPACE}%{WORD:Severity}%{SPACE}%{SPACE}%{SPACE}%{SPACE}%{SPACE}(?\w+.\w+.\w+)%{SPACE}%{WORD:Action}(?.)%{SPACE}(?.)(?.)%{WORD:Protocol}(?.)(?<interface_IN>(?<=|)(.?)(?=|))(?.)%{IPV4:src}(?.)(?<src_port>\d+)(?.)%{COMMONMAC:mac}(?.)%{IPV4:dst}(?.)(?<dst_port>\d+)(?.)(?.)(?<interface_OUT>(?<=|)(.?)(?=|))(?.)(?.)(?(?<=|)(.?)(?=|))" }}
mutate { remove_field => [ "_version", "@version", "_score", "_type", "separator1", "separator2", "separator3", "separator4", "separator5", "separator6", "separator7", "separator8", "separator9", "separator10", "separator11", "separator12", "separator13", "separator14", "separator15", "separator16", "separator17", "separator18", "separator19", "message", "misc", "port", "type", "score", "rest" ] }}
else { grok { match => { "message" => { "(?<\d+>)(?\w+\s\d+\s\d+.\d+.\d+)%{SPACE}%{HOSTNAME}%{SPACE}(?\d(.?)(:))%{SPACE}%{SPACE}%{WORD:Severity}%{SPACE}%{SPACE}%{SPACE}%{SPACE}%{SPACE}(?\w+.\w+.\w+)%{SPACE}%{WORD:Action}(?.)%{SPACE}%{WORD:Org}(?.)%{WORD:Protocol}(?.)(?<interface_IN>(?<=|)(.?)(?=|))(?.)%{IPV4:src}(?.)(?<src_port>\d+)(?.)%{COMMONMAC:mac}(?.)%{IPV4:dst}(?.)(?<dst_port>\d+)(?.)(?\w+)(?.)(?<interface_OUT>(?<=|)(.?)(?=|))(?.)(?(?<=|)(.?)(?=|))(?.)(?(?<=|)(.?)(?=|))(?.)%{IPV4:src_NAT}(?.)%{IPV4:dst_NAT}(?.)(?(?<=|)(.?)(?=|))(?.)(?<packet_count>(?<=|)(.?)(?=|))(?.)(?(?<=|)(.?)(?=|))(?.)(?(?<=|)(.?)(?=|))(?.)(?(?<=|)(.?)(?=|))(?.)(?(?<=|)(.*?)(?=|))%{GREEDYDATA:rest}" }}}
mutate { remove_field => [ "_version", "@version", "_score", "_type", "separator1", "separator2", "separator3", "separator4", "separator5", "separator6", "separator7", "separator8", "separator9", "separator10", "separator11", "separator12", "separator13", "separator14", "separator15", "separator16", "separator17", "separator18", "separator19", "message", "misc", "port", "type", "score", "rest" ] }}
}
output {
elasticsearch { hosts => ["localhost:9200"] }
file {
path => "C:\Users\Administrator\Desktop\LogTest\test.log"
}
}
and I get this error:
Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, => at line 14, column 1080 (byte 2275) after filter { \n\t\tif "Drop:" in [message]
I seem to miss something but cannot see what exactly. If I comment out the else statement and build the filter with only filter { grok { match => { GROKFILTER}}} than it works... also the if part is working by itself, but the IF THEN I am not able to link together...
thanks for any input in advance!
Regards,
Gergö