Logstash ruby length does not count correctly

The execution_length_output count string correctly, but execution_length_input string is to low.

ruby {
code => "event.set('execution_length_output', event.get('[execution][output]').length)
event.set('execution_length_iput', event.get('[execution][input]').length)"
}

This should work.

Conf

input { generator { lines => ['{"execution.output":"five1", "execution.input": "sixsix"}'] count => 1 codec => "json" } }
filter {
  	ruby {
      code => '
        event.set("execution_length_output", event.get("execution.output").length)
        event.set("execution_length_input", event.get("execution.input").length)
      '      
  	}
}
output { stdout { codec => "json" } }

Output

{
  "execution.output": "five1",
  "execution_length_input": 6,
  "execution_length_output": 5,
  "execution.input": "sixsix"
}

thx for help!

1 Like

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