I have a logstash configuration file (5.2:alpine) and want to use the same file for development and production environments.
I have loaded in environment variables and confirmed they exist.
However, when trying to change the output based on the environment variable (in this example [environment] is configured in the filter), the elasticsearch configuration combines both declarations and does not see them as unique settings, causing development to fail:
output {
if [environment] == "development" {
elasticsearch {
hosts => ["${ELS_HOSTNAME}:${ELS_PORT}"]
index => "%{els_index}"
action => "%{els_action}"
document_type => "%{type}"
document_id => "%{id}"
}
stdout {
codec => rubydebug
}
} else {
elasticsearch {
hosts => ["${ELS_HOSTNAME}:${ELS_PORT}"]
ssl => "${ELS_SSL:false}"
ssl_certificate_verification => "${ELS_SSL_VERIFY:false}"
healthcheck_path => "https://${ELS_USERNAME:guest}:${ELS_PASSWORD:guest}@${ELS_HOSTNAME}:${ELS_PORT}/"
absolute_healthcheck_path => "true"
user => "${ELS_USERNAME:guest}"
password => "${ELS_PASSWORD:guest}"
index => "%{els_index}"
action => "%{els_action}"
document_type => "%{type}"
document_id => "%{id}"
}
}
}
Is my approach to this incorrect or is this a potential bug?