apaulsen
(Agnes)
February 8, 2019, 10:25pm
1
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.
apaulsen
(Agnes)
February 10, 2019, 9:26am
3
apaulsen:
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)])
"
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
apaulsen
(Agnes)
February 11, 2019, 11:56am
4
apaulsen:
IO.read
IO.read -> cannot access Input file via Pipeline, so this is not a solution
system
(system)
Closed
March 11, 2019, 11:57am
5
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.