简体   繁体   English

Logstash 到 Opensearch,_dateparsefailure 标记

[英]Logstash to Opensearch , _dateparsefailure tag

I have some problems while using logstash to opensearch.我在使用 logstash 打开搜索时遇到了一些问题。

filter{
    grok {
            patterns_dir => ["/etc/logstash/conf.d/patterns"]
            match => [ "message","%{DATE_FORM:logdate}%{LOGTYPE:logtype}:%{SPACE}%{GREEDYDATA:msgbody}" ]
    }
    date {
            match => ["logdate", "yyyy.MM.dd-HH.mm.ss:SSS"]
            timezone => "UTC"
            target=>"timestamp"
    }

    mutate {
            remove_field => ["message"]
            add_field => {
                    "file" => "%{[@metadata][s3][key]}"
            }
    }
}

This is the conf file I'm using for logstash.这是我用于 logstash 的 conf 文件。 In the opensearch console在打开搜索控制台

@timestamp : Dec 15, 2022 @ 18:10:56.975
logdate [2022.12.10-11.57.36:345]
tags _dateparsefailure

The timestamp, logdate are different and _dateparsefailure error occurs.时间戳、日志日期不同,出现_dateparsefailure 错误。

In the raw logs, it starts with在原始日志中,它以

[2022.12.10-11.57.36:345]

this format.这种格式。

Right now,现在,

logdate : raw log's timestamp
@timestamp : the time that log send to opensearch

I want to match logdate and @timestamp.我想匹配 logdate 和 @timestamp。 How can I modify the filter.date.match part to make the results of the logdate and @timestamp filters the same?如何修改 filter.date.match 部分以使 logdate 和 @timestamp 过滤器的结果相同?

If you have multiple times you can have more than one filter.date.match , you can do this:如果你有多次你可以有多个filter.date.match ,你可以这样做:

filter{
    date {
            match => ["logdate", "yyyy.MM.dd-HH.mm.ss:SSS"]
            timezone => "UTC"
            target=>"logdate"
    }
    date {
            match => ["@timestamp", "yyyy.MM.dd-HH.mm.ss:SSS"]
            timezone => "UTC"
            target=>"@timestamp"
    }
}

If your time field has multiple formats, you can do this:如果您的时间字段有多种格式,您可以这样做:

date {
  match => [ "logdate", "yyyy.MM.dd-HH.mm.ss:SSS", "third_format", "ISO8601" ]
  target=> "@timestamp"
}

Reference: https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match参考: https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match

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

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