I used the bottom one from you've recommended,
sorry if my information before is not complete enough
here was my config :
if "iris-uat" in [openshift][kubernetes][namespace_name] {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-uat-%{+YYYY.MM}"
}
}
else if "iris" in [openshift][kubernetes][namespace_name] {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-dev-%{+YYYY.MM}"
}
}
I think the anomaly happened because "iris" and "iris-uat" is counted as same because I used "in" conditional,
rather I use "==" conditional to add tag and then use "in" conditional for the output
here's my code on my filter section:
if [openshift][kubernetes][namespace_name] == "iris" {
mutate { add_tag => "iris" }
} else if [openshift][kubernetes][namespace_name] == "iris-uat" {
mutate { add_tag => "iris-uat" }
}
and this on my output section :
if "iris" in [tags] {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-dev-%{+YYYY.MM}"
}
}
else if "iris-uat" in [tags] {
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-uat-%{+YYYY.MM}"
}
}
else {
#stdout { codec => rubydebug }
elasticsearch {
hosts => ["xxx:9200"]
index => "iris-new-%{+YYYY.MM}"
}
}
Now it is fixed, thanks for your explanation, because now I can clearly know how the syntax work