简体   繁体   English

筛选日期Logstash

[英]Filter Date Logstash

I just started with Logstash parsing a CSV document. 我刚开始使用Logstash解析CSV文档。 CSV document only has two columns "Date" and "High". CSV文档只有两列“日期”和“高”。 I have read various configurations to parse a date but I can not, giving me error in that field. 我已经阅读了各种配置来解析日期,但是我做不到,这给我一个错误。 The date has the format DD / MM / YYYY and error tells me the following: 该日期的格式为DD / MM / YYYY,并且错误告诉我以下内容:

Failed parsing date from field {:field=>"Date", :value=>"Date", :exception=>"Invalid format: \"Date\"", :config_parsers=>"dd/MM/YYYY", :config_locale=>"default=es_ES", :level=>:warn}

This is my configuration file to filter Logstash: 这是我用来过滤Logstash的配置文件:

input {
  file {
    path => "/path/to/data.csv"
    start_position => "beginning"    
  }
}

filter {
  csv {
      separator => ","
      columns => ["Date","High"]
  }

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

  mutate {convert => ["High", "float"]}

}

output {  
    elasticsearch {
        hosts => ["localhost:9200"]
    action => "index"
    index => "machine"
    workers => 1
    }
    stdout { codec => rubydebug }
}

Thank you!! 谢谢!!

In your date plugin try to change the letter cases in the match setting. 在您的date插件中,尝试更改match设置中的字母大小写。 Something like this: 像这样:

  date{
      match => [ "Date", "DD/MM/YYYY" ]
  }

If not helping try to make them all lowercase. 如果没有帮助,请尝试使它们全部变为小写。

The format string dd/MM/yyyy should work. 格式字符串dd/MM/yyyy应该可以。 You can find detailed specifications for formatting strings in the JodaTime documentation . 您可以在JodaTime文档中找到格式化字符串的详细规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM