Need to do a calculation in logstash

logstash input is elasticsearch and there is field called 'check' in input index.
when ever read the documents in this index need to increment check by 1.

I used ruby filter for this.
ruby{code => "event.set('check',[event.get('check_')].to_i + 1)"}

getting following error
[2019-12-09T18:48:30,925][ERROR][logstash.filters.ruby ] Ruby exception occurred: undefined method `to_i' for ["0"]:Array

Remove the square brackets around event.get('check_'). They turn it into an array and prevent .to_i working. Square brackets are used to reference fields in the logstash configuration, not in ruby.

thx Badger, it got work.

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