Reading environmental values in logstash config file in input/output


(Biswajit86) #1

Is there a way to read environmental values in logstash config file . I want to pass in an env value to write test cases for my logstash configs
For ex I want to do the following in my logstash config file

input {
 if [ $ENV_VALUE] = test {
    stdin{}
}else{
    Default config
}
}
filter {..}
output
{
 if [ $ENV_VALUE] = test {
  stdout { codec => rubydebug }
}else{
   Default config
}

}

(Magnus B├Ąck) #2

I was going suggest using an environment filter here but since you want to wrap inputs with conditionals that's probably not going to fly. I suggest you extract your inputs and outputs into separate files and choose which ones to include when you invoke Logstash.


(Joe Lawson) #3

I know this isn't exactly what your looking for but check out this
suggestion:


(Biswajit86) #4

@Joe_Lawson , thanks for the link.

I think i will rather use logstash with a dynamic string as an input instead of a file name to achieve my functionality , which is @magnusbaeck suggestion


(system) #5