简体   繁体   中英

logstash 5 ruby filter

I've recently upgraded an elk-stack cluster from an old version to 5.1 and although everything looks great, I have an exception occurring frequently in the logstash log, which looks like this:

logstash.filters.ruby Ruby exception occurred: Direct event field    references (i.e. event['field']) have been disabled in favor of using event get and set methods (e.g. event.get('field')). Please consult the  Logstash 5.0 breaking changes documentation for more details.

The filter I have looks like this:

    filter {
    ruby {
        init => "require 'time'"
        code => "event.cancel if event['@timestamp'] < Time.now-(4*86400)"
    }
}

Any suggestions ?

The exception contains the answer:

Direct event field references (ie event['field']) have been disabled in favor of using event get and set methods (eg event.get('field')).

From that, it seems like event.get('@timestamp') is now preferred over event['@timestamp'].

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM