Logstash过滤器解析日期格式

时间:2016-01-01 19:53:41

标签: logstash

我正在尝试解析csv并将其输出为弹性,我遇到日期格式问题

Date,In1,In2,In3,In4,In5,In6 
31/12/2015,1527.96,1527.95,1528.74,1534.43,1525.76,716485827
30/12/2015,1534.59,1532.26,1527.96,1534.55,1526.47,716485827
29/12/2015,1524.67,1532.47,1534.59,1535.73,1530.90,717176468
28/12/2015,1533.85,1533.09,1524.67,1533.16,1523.20,710573918

logstash.config

# test file
input {
   file {
      path => "/config/file.csv"
      type => "core2"
      start_position => "beginning"
   }
}

filter {
 csv {
     separator => ","
    }
}

output {
    elasticsearch {
        action => "index"
        hosts => ["elastic:9200"]
        index => "ta25"
        workers => 1
    }

}

如何将Date列解析为logstash过滤器?

1 个答案:

答案 0 :(得分:1)

使用过滤日期https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date

filter {
  date {
    match => [ "Date", "dd/mm/YYYY" ]
  }
}