Using hash variable in output

(Exocomp) #1

Is it possible to use hash as a variable in the output section in logstash. Here is a simple example to demonstrate what I mean:

ruby {
	code => "
		count = { 'metric1' => 1, 'metric2' => 2 };
		event.set('statsd_count', count);

So basically create a "statsd_count" variable that is a hash having a couple values.

output {
  statsd {
    host => ""
    count => "%{statsd_count}"

Then use the statsd_count as a variable in the count property. I get an error "This setting must be a hash".

This is a simple example, but in practice the hash values can be different based on the event type so in order to handle that case I'd have to use multiple if statements in the output section each having a separate statsd block which I'd like to avoid.

(system) #2

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