Hi all,
logstash v.7.17.8
I have ~45 metrics to calculate, here is the example, code and results:
ruby {
code => "
if !event.get('[Package2VersionCreatesWithoutValidation][Max]').nil? and !event.get('[Package2VersionCreatesWithoutValidation][Remaining]').nil?
Max = event.get('[Package2VersionCreatesWithoutValidation][Max]')
Remaining = event.get('[Package2VersionCreatesWithoutValidation][Remaining]')
Used = Max - Remaining
if Max == 0
UsedPercentage = 0
else
UsedPercentage = Used.to_f/Max * 100.00
end
event.set('[Package2VersionCreatesWithoutValidation][Used]', Used)
event.set('[Package2VersionCreatesWithoutValidation][UsedPercentage]', UsedPercentage.round(2))
end
"
}
another example:
as you can see, usually it works fine but sometimes i have totally incorrect values.
Do you have any idea what's wrong in my code?
Best
Patryk