Logstash创建和访问阵列 [英] Logstash Create and Access Array

查看:130
本文介绍了Logstash创建和访问阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在用于设备的logstash配置文件中创建一个数组,然后通过该数组访问我正在创建的新字段的值.例如:

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.

推荐答案

如果没有任何过滤器插件可以帮助您,则可以尝试使用ruby,然后自己做. 例如

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.

这篇关于Logstash创建和访问阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆