The Logstash configuration item is written repeatedly

Distinguish according to Tags

But need to repeat it in if
"hosts ","user","password"

I have a lot of "if" that I have to write multiple times

output {
    if "server4-apache-access" in [tags] {
        elasticsearch {
            hosts => ["http://localhost:9200"]
            index => "server4-apache-access-%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
            user => "elastic"
            password => "elastic"
        }
    }
    if "server4-apache-error" in [tags] {
        elasticsearch {
            hosts => ["http://localhost:9200"]
            index => "server4-apache-error-%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}"
            user => "elastic"
            password => "elastic"
        }
    }
}

That's the solution I've found so far

But I don't think this is particularly good :stuck_out_tongue_closed_eyes: :stuck_out_tongue_closed_eyes:

https://www.elastic.co/guide/en/logstash/current/environment-variables.html

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