Implementing Event dependent configurations using Java output plugins

Following from the issue below:

I am looking to access configurations that are evaluated based on the event

https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html

output {
  file {
    path => "<changed value per event>"
  }
}

An example of usage is the configuration above. How would you configure and access it in your output function within your Plugin class.

@danhermann

@Xucito, let's say you set path to something like /path/to/my/file/log-%{type}. In that scenario, you'd expect that events coming through with types of error, warn, and info would be written to the files log-error, log-warn, and log-info, respectively. Inside the plugin's output() method, you'd have to retrieve the value of each event's type field, check if the currently-open file matched that name and if not, open or create a file with the proper name before writing to it.

Of course, if there were a large number of different values in the event's type field, you could end up creating lots of different files which would probably not be ideal.

I see, so the configuration itself is still only set during initialization however it will contain the instructions of where in the event object to look. The approach would be that one of fields contains the actual payload you may want to send and the other fields would contain the configuration values.

i.e. in syslog output plugin, the message field is assumed to be the actual payload

Thanks for your help

Ah, I see now what you were asking. Yes, your above statement is correct and that's the way per-event configuration values work.

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