日期记录的问题

时间:2015-08-08 20:00:44

标签: date csv elasticsearch logstash kibana

我在CSV文件中记录了此模式中的日期字段“24/09/2014”,但是当我使用Logstash读取文件时,日期字段具有字符串类型。

csv file example:
fecha,cant,canb,id,zon
24/09/2014,80,20,1.5,2
01/12/2014,50,25,1,3

我的Logstash配置文件:

input {  
  file {
    path => "path/to/data.csv"
    start_position => "beginning"    
  }
}
filter {  
  csv {
      separator => ","
      columns => ["fecha","cant","canb","id","zon"]
  }
date {
match=> ["fecha","dd/MM/yyyy"]
}
  mutate {convert => ["cant", "integer"]}
  mutate {convert => ["canb", "integer"]}
  mutate {convert => ["id", "float"]}
}
output {  
    elasticsearch {
        action => "index"
        host => "localhost"
        index => "barrena"
        workers => 1
    }
    stdout {}
}

谢谢!

1 个答案:

答案 0 :(得分:0)

日期将被复制到名为@timestamp的字段(日期过滤器执行此操作),此字段将为日期格式。 使用日期过滤器后,您可以安全地删除fetcha字段。