Logstash - Use of Memorize plugin

2019-02-27 17:13发布

Trying to use the "memorize" plugin like so:

            if [message] =~ /matching event/ {

                grok {
                    match => [ "message", "%{mymatch:datetime}" ]
                }

                memorize {
                    field => [datetime]
                }
            }

            if [message] =~ /another event/ {
                mutate {
                    add_field => {
                        datetime => "%{datetime}"
                    }
                }
            }

A field called datetime is being added, but it only contains the text "%{datetime}". Clearly I'm using the plugin incorrectly. Can anyone advise on how to reference the memorized value please?

Thanks.

1条回答
孤傲高冷的网名
2楼-- · 2019-02-27 17:37

The way that plugin works would be like this:

        if [message] =~ /matching event/ {
            grok {
                match => [ "message", "%{mymatch:datetime}" ]
            }
        }
        # either save the datetime or add it based on last value
        memorize {
           field => 'datetime'
           default => '00:00:00'
        }

        if [message] =~ /another event/ {
            # datetime has already been added based on the above line
        }
查看更多
登录 后发表回答