Add message_length field

I am trying to add calculated "message_length" field that would be a representation on character count in "message" field. Info is coming in from winlogbeat/filebeat/syslog if that makes any difference.

This is the code I currently have:

filter {
  ruby {
	code => "event['message_length'] = event['message'].length"

But it's producing 0 results. No value is added into message_length field.

What am I doing wrong?

Unless you are running an old version (4.x perhaps) that would have to be

code => "event.set('message_length', event.get('message').length)"

Thank you! That works, running 7.x.

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