How to move ruby code from logstash.conf into ingest pipeline?

I've a logstash configuration file which contains ruby code.
How can I script the ruby part of the logstash filter in ingest pipeline?

It's a server with filebeat.
All part except the ruby code I "moved" into the ingest pipline definition.

my_logstash.conf

filter {
csv {
columns => ['BL','MA',OffsetByte,'LengthByte']
separator => ";"
autogenerate_column_names => false
}
mutate {
add_field => { "my_stats" => "%{path}" }
convert => {
"LengthByte" => "integer"
}
}
ruby {
code => "
stats = IO.read(event.get('my_stats'), event.get('LengthByte'), event.get('OffsetByte') )
linecount = stats.scan(/\n/).count
event.set('Statistics', stats[0..-(linecount+1)])
"
}

}
}

Ingest node pipelines do not support Ruby, so the only way I can think of would be to try and move this logic into a painless script.

I'll give a try

"filters": [
{
"ruby": {
"code": "stats = IO.read(event.get('path_stats'), event.get('LengthByte'),event.get('OffsetByte')) linecount = stats.scan(/\n/).count event.set('Statistics', stats[0..-(linecount+1)])"
}
}
],

later more, when tested

IO.read -> cannot access Input file via Pipeline, so this is not a solution

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