我正在尝试使用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.
请建议我做出哪些改变。
答案 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 format与Date
字段中的内容相匹配。