I am using a number of environment variables in my logstash config which all work well, except for one. In my output section I am trying to use a variable in an if.. then statement and it does not appear to be working. Perhaps it is my syntax. The user, password and proxy variables substitute correctly, but the code always takes the first branch regardless of the value of ${LS_USE_PROXY}. What am I doing wrong?
if "${LS_USE_PROXY}" == "true" {
elasticsearch {
hosts => ["https://xxx.eu-central-1.aws.cloud.es.io:443"]
index => "%{[@metadata][index_alias]}"
user => "${LS_ELASTIC_USER}"
password => "${LS_ELASTIC_PASSWD}"
proxy => "${LS_PROXY}"
}
} else {
elasticsearch {
hosts => ["https://xxx.eu-central-1.aws.cloud.es.io:443"]
index => "%{[@metadata][index_alias]}"
user => "${LS_ELASTIC_USER}"
password => "${LS_ELASTIC_PASSWD}"
}
}