Are constants and/or variabales available in Logstash?

I am reusing same values (see integer 100 example below) in my logstash configuration file. Is there way I can define constant at the beginning of the file i.e. THRESHOLD=60 for later use in the config file

if [SOMETHING][count] > 100 {

        exec {
              command => "iquery-notify -time=60"
            }

}

also in this particular case is it possible to pass variable %{URL} to exec command ?

        exec {
              command => "iquery-notify -time=60 -url=**\"%{URL}\"**"
            }

I am reusing same values (see integer 100 example below) in my logstash configuration file. Is there way I can define constant at the beginning of the file i.e. THRESHOLD=60 for later use in the config file

You can access environment variables via ${name-of-variable} but Logstash has no constant concept of its own (unless you store the value in a field).

also in this particular case is it possible to pass variable %{URL} to exec command ?

Yes, assuming there is a URL field.

1 Like

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