【问题标题】:Logstash date parsing failing when using default target使用默认目标时 Logstash 日期解析失败
【发布时间】:2018-11-28 09:52:23
【问题描述】:

我无法使用 logstash 日期插件解析日期字段,我的配置如下:

if "test" in [tags] {
    csv {
        separator => ","
        columns => [ "value", "received_date" ]
        convert => {
             "value" => "float"
        }
    }
    mutate {
        gsub => [ "received_date" , ".\d*$" , ""]
    }
    date {
        match => [ "received_date", "yyyy-MM-dd HH:mm:ss" ]
    }
}

我得到错误:

[2018-06-19T11:51:20,583][WARN][logstash.outputs.elasticsearch] 无法将事件索引到 Elasticsearch。 {:status=>400, :action=>["index", {:_id=>"f2d34d84-1ea4-4510-8237-2329a4d1ffba", :_index=>"logstash-2018.06.19", :_type=>"doc", :_routing=>nil}, #], :response=>{"index"=>{"_index"=>"logstash-2018.06 .19", "_type"=>"doc", "_id"=>"f2d34d84-1ea4-4510-8237-2329a 4d1ffba", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"无法解析 [received_date]", "caused_by"=>{"type"=> "illegal_argument_exception", "reason"=>"无效格式:\"2018-06-19 11:51:15\" 格式错误在 \" 11:51:15\""}}}}}

如果我添加一个目标:

    date {
        match => [ "received_date", "yyyy-MM-dd HH:mm:ss" ]
        target => "received_date"
    }

然后它可以工作,但是时间戳字段采用logstash收到输入的日期,这不是我想要的。

为什么目标会影响日期解析?

【问题讨论】:

    标签: date parsing elasticsearch logstash


    【解决方案1】:

    timestamp 字段由于某种原因在弹性搜索中被映射为日期。

    您可以删除timestamp字段,

    date {
      locale => "en"
      remove_field => ["timestamp"]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-06
      • 1970-01-01
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      • 2019-08-17
      相关资源
      最近更新 更多