Logstash - 过滤类型

时间:2016-09-27 22:29:40

标签: logstash logstash-configuration

这是我的Logstash配置文件。我有多个配置文件来解析不同的CSV文件,我希望每个CSV都进入一个单独的索引。我试图通过在输入过滤器上使用类型然后使用条件来查看类型是否匹配,如果是,则将其发送到正确的索引。唯一的问题是,我必须遗漏一些东西,因为它不起作用!

input {
    file {
            path => "/reports/device-availability.csv"
            start_position => "beginning"
            type => "device-availability"
    }
}

filter {

    if [type] == "device-availability" {
            csv {
                    separator => ","
                    columns => ["Company","Date","Device","IP Address","Device Type","Availability","Uptime"]
            }
            date {
                    match => ["Date", "MMM-yy", "yy-MMM", "MM/yy", "M/yy"]
                    locale => "en"
            }
            mutate {
                    convert => { "Availability"  => "float" }
                    convert => { "Uptime" => "float" }
            }
    }
}

output {
    if [type] == "device-availability" {
            elasticsearch {
                            action => "index"
                            hosts => "localhost"
                            index => "device-availability"
                            workers => 1
            }

            stdout {
            }

            file {
                    path => "/output/logstash/device-availability.log"
            }
    }
}

0 个答案:

没有答案