我们在csv文件中有来自外部资源的数据:
orderid,OrderDate,BusinessMinute,Quantity,Price
31874,01-01-2013,00:06,2,17.9
数据在一列中有date
,在另一列中有time
- 我需要通过将这两列组合在一起来生成时间戳。
我正在使用csv filter
使用logstash中的以下配置从文件中读取上述数据 - 这正在生成自己的时间戳:
input {
file {
path => "/root/data/import/Order.csv"
start_position => "beginning"
}
}
filter {
csv {
columns => ["orderid","OrderDate","BusinessMinute","Quantity","Price"]
separator => ","
}
}
output {
elasticsearch {
action => "index"
host => "localhost"
index => "demo"
workers => 1
}
}
如何将OrderDate + Business Minute
组合为@timestamp
?
答案 0 :(得分:16)
使用mutate filter将OrderDate和BusinessMinute字段合并为一个(临时)字段,然后使用date filter并删除该字段,如果该字段成功。
filter {
mutate {
add_field => {
"timestamp" => "%{OrderDate} %{BusinessMinute}"
}
}
date {
match => ["timestamp", "..."]
remove_field => ["timestamp"]
}
}