Hello @leandrojmp ,
I did the changes you have suguested but still i am getting the same error:
ruby - Ruby exception occurred: uninitialized constant LogStash::Filters::Ruby::ReloadedAmount {:class=>"NameError", :backtrace=>["org/jruby/RubyModule.java:3766:in `const_missing'",
I am pasting below my entire conf file:
echo "
Time User AccBal accBalBef accBalAft amountReloaded
========================================================================================
19:10:29 someUser someClient 24205700 331510000 307304300
" | /usr/share/logstash/bin/logstash -e 'input { stdin {} } filter {
if [message] =~ /^=.*$/ {
drop { }
} else if [message] =~ /^Time.*$/ {
drop { }
}
if [message] == "" {
drop { }
}
grok {
match => { "message" => [ "%{TIME:time}\s*%{USERNAME:User}\s*%{USER:ActorId}\s*%{NUMBER:AccountBef}\s*%{NUMBER:AccountAft}\s*%{NUMBER:ReloadedAmount}" ] }
}
grok {
match => {"[log][file][path]" => "/%{GREEDYDATA}/balanceReload_%{YEAR:year}%{MONTHNUM:month}%{MONTHDAY:day}\.txt$"}
add_field => ["Ndate", "%{year}-%{month}-%{day} %{time}" ]
}
date {
match => ["Ndate", "yyyy-MM-dd HH:mm:ss"]
target => "@timestamp"
timezone => "UTC"
remove_field => [ "year", "month", "day" ]
}
mutate {
add_field => { "[@metadata][field]" => "ReloadedAmount" }
convert => { "AccountBef" => "integer" }
convert => { "AccountAft" => "integer" }
convert => { "ReloadedAmount" => "integer" }
}
ruby {
code => "event.set('ReloadedAmount', event.get('ReloadedAmount').to_f / 100)"
}
}
output {
stdout {}
}'
below is the output i get:
[ERROR] 2022-08-14 10:02:07.766 [[main]>worker3] ruby - Ruby exception occurred: uninitialized constant LogStash::Filters::Ruby::ReloadedAmount {:class=>"NameError", :backtrace=>["org/jruby/RubyModule.java:3766:in `const_missing'", "(ruby filter code):2:in `block in filter_method'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.8/lib/logstash/filters/ruby.rb:96:in `inline_script'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-filter-ruby-3.1.8/lib/logstash/filters/ruby.rb:89:in `filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:159:in `do_filter'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:178:in `block in multi_filter'", "org/jruby/RubyArray.java:1821:in `each'", "/usr/share/logstash/logstash-core/lib/logstash/filters/base.rb:175:in `multi_filter'", "org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:134:in `multi_filter'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:300:in `block in start_workers'"]}
{
"event" => {
"original" => "19:10:29 someUser SomeClient 24205700 331510000 307304300"
},
"@timestamp" => 2022-08-14T05:32:07.579729Z,
"time" => "19:10:29",
"AccountAft" => 331510000,
"ActorId" => "someClient",
"ReloadedAmount" => 307304300,
"AccountBef" => 24205700,
"User" => "someUser",
"@version" => "1",
"message" => "19:10:29 someName someClient 24205700 331510000 307304300",
"host" => {
"hostname" => "spider"
},
"tags" => [
[0] "_grokparsefailure",
[1] "_rubyexception"
]
}
[INFO ] 2022-08-14 10:02:08.009 [[main]-pipeline-manager] javapipeline - Pipeline terminated {"pipeline.id"=>"main"}