Hello I've made a conditional statement in the output of logstash, but the else statement doesn't work. When I send INFO logs they get into the if statement, but when I send logs different from these, they don't get into the else statement and they are not shown in tpms-system index.
Here is my output section:
output{
stdout{
codec => dots
}
if [message] =~ "\D\[INFO\s\]:.*\[ELASTICSEARCH\].*" or [message] =~ "\D\[INFO\]:.*\[ELASTICSEARCH\].*" {
elasticsearch {
hosts => ["https://localhost:9200"]
user => logstash
password => logstash
ssl => true
ssl_certificate_verification => false
document_id => "%{fingerprint}"
index => "beat-tpms"
}
}else{
elasticsearch {
hosts => ["https://localhost:9200"]
user => logstash
password => logstash
ssl => true
ssl_certificate_verification => false
document_id => "%{fingerprint}"
index => "tpms-system"
}
}
}
The regex expression is correct because I'm using the same in filebeat.yml file to recieve only these INFO logs and is working.