Logstash Create and Access Array

2019-05-21 17:51发布

I want to create an array in the logstash config file that is for devices and then access the array value by for a new field that I am creating. example:

filter {
     array_devicetype => ["Cisco ASA", "Cisco 3750"]
     mutate {
            add_field => { "Device Type" => "%{array_devicetype[0]}"
     }
}

Yet, no luck. Can someone help me out with this? Thanks.

标签: logstash
1条回答
ゆ 、 Hurt°
2楼-- · 2019-05-21 18:24

If there is no any filter plugin can help you, you can try to use ruby and then do it yourself. For example

filter {
    ruby {
            code => "
                    event['array_devicetype'] = ['Cisco ASA', 'Cisco 3750']
                    event['Device Type'] = event['array_devicetype'][0]
            "
    }
}

Use this filter can do what you want. FYI.

查看更多
登录 后发表回答