Hi Experts,
I' m using ruby code to parse my target log.
Here is the source code:
if "_xmlparsefailure" not in [tags]{
        ruby {
                code => '
                        res = []
                        pmMeasInfo = event.get("[parsed][measData][0][measInfo]")
                        pmMeasInfo.each do |pr|
                                hash = Hash.new
                                i = 0
                                pmmeasValue = pr["measValue"][0]
                                pmmeasType = pr["measType"][0]
                                hash["measObJ"] = pmmeasValue["measObjLdn"]
                                pmmeasType.each do |pt|
                                        key = pt["content"]
                                        value = pmmeasValue["r"][#i]["content"].to_i
                                        hash[key] = value
                                        i = #i + 1
                                end
                                res.push(hash)
                        end
                        event.set("pm",res)
                '
        }
}
but when I start the logstash, here is the error report is fired:
[2019-08-30T16:11:23,024][ERROR][org.logstash.Logstash    ] java.lang.IllegalStateException: Logstash stopped processing because of an error: (SyntaxError) (ruby filter code):18: syntax error, unexpected tIDENTIFIER
                                                    i = #i + 1
How can I realize  “i = i + 1" operation in ruby code section?
Thank you.,