Logstash: Accessing the environment variable from rule config file through "dynamic key" reference

(Rajat Katyal) #1

We have an requirement to read environment variable from rule config file through dynamic key reference instead of static key reference.
However, It seems Logstash does not support reading Environment variable through dynamically rendered key i.e. in our code we need to access environment variable: IP_Source HOST IP_TYPE.
Here "Source HOST IP" is dynamically initialized field on the basis of source of log message.
Dynamic key Code: ${IP_%hostip_TYPE}
Static key Code: ${IP_10_13_204_11_TYPE}

With static key it is able to fetch but with dynamically initialized key it failed to read from environment.

Please guide on the resolution of this issue

(Magnus Bäck) #2

The syntax would have to be ${IP_%{hostip_TYPE}} but I'm pretty sure that doesn't work. You should be able to accomplish what you want with a ruby filter.

(Rajat Katyal) #3

Tried this but does not work. I believe there is no support in Logstash for this.

(Magnus Bäck) #4

Tried what, a ruby filter? That'll definitely work.

(Rajat Katyal) #5

Sure will try Ruby filter

(system) #6

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