logstash csv的未知设置'convert'{:level =>:error}

时间:2016-09-05 23:00:25

标签: date csv logstash

我正在尝试使用Logstash将CSV文件导入Elastic Search。这是我的配置文件

input {
        file    {
                path => "c:/Elkwin_Free_x64/input/export.csv"
                start_position => beginning
        }
}
filter {
        csv {
                columns => [
                        "Date",
                        "Transaction",
                        "Name",
                        "Memo",
                        "Amount"
                ]
                separator => ","
                convert => {"Date" => "date"}
        }
}
output {
        elasticsearch {
                action => "index"
                host => "localhost"
                index => "USB-%{+YYYY.MM}"
                workers => 1
        }

        stdout {
                codec => rubydebug
        }
}

我希望将“Date”列转换为“date”类型而不是“string”。但是,当我运行logstash时,我收到以下错误消息

 c:\Elkwin_Free_x64\logstash\bin>logstash -f "C:\Elkwin_Free_x64\logstash\conf\logstash.conf
 io/console not supported; tty will not be manipulated
 Unknown setting 'convert' for csv {:level=>:error}
 Error: Something is wrong with your configuration.
 You may be interested in the '--configtest' flag which you can
 use to validate logstash's configuration before you choose
 to restart a running system.

请建议我做出哪些改变。

1 个答案:

答案 0 :(得分:1)

csv/convert设置仅出现在Logstash 2.2中,因此,如果您使用旧版本的Logstash,那就是它抱怨的原因。

您可以升级到Logstash 2.2,2.3或最好是2.4或使用date filter代替(注意mutate/convert过滤器不支持日期转换):

filter {
        csv {
                columns => [
                        "Date",
                        "Transaction",
                        "Name",
                        "Memo",
                        "Amount"
                ]
                separator => ","
        }
        date {
            match => ["Date", "ISO8601", "d/m/yyyy"]
            target => "Date"
        }
}

PS:我已选择ISO8601,但请确保date formatDate字段中的内容相匹配。