hi Everyone!
My goal is to 'implement' filter to process only traces with specific levels.
Perfect solution: levels should be defined in separated file or environment variable.
So, I would like to achive it in this way:
if [level] in [${MY_LEVEL_FILTER}] { ... // to some logic } else { drop {} }
For some reason above solution does not work correctly, nor:
if [level] == MY_LEVEL_OK_1 or [level] == MY_LEVEL_OK_2 {
Hard-coded IF-statement works:
if [level] in ["INFO", "ERROR"] { ... }
I have got Logstash 2.4. It works as a service with flag --allow-env
(So it is according to the documentation; and I have noted 'experimental' word)
This is what I did to make 'environemt variables' achievable:
- In /etc/init.d/logstash file I put
export MY_LEVEL_FILTER='"INFO", "ERROR"' export MY_LEVEL_OK_1=INFO export MY_LEVEL_OK_2=ERROR
( just to make sure I call
sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/mylogstash1.conf --configtest
)
and I call:
sudo service logstash start
I have got some enviroment variables, e.g.:
MY_INPUT_FILE_NAME=/path/to-input-file MY_LEVEL_FILTER=["INFO", "WARN", "ERROR"]
Below example works perfectly fine:
input { file { path => "${MY_INPUT_FILE_NAME}" } }
What is more, in other plugin (in Ruby source code)
I have got: puts ENV['MY_LEVEL_FILTER']
which displays desired string.
Maybe ENV in Ruby source code is something else than in logstash configuration file?
Maybe above pieces of information will be useful for someone.
Thank you for helping.