# Unable to parse date in grok and filters

**URL:** <https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988>\
**Category:** Logstash\
**Created:** [February 2, 2021, 1:41pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988 "2021-02-02T13:41:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RFeiten](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@RFeiten](https://discuss.elastic.co/u/RFeiten)\
**Post date:** [February 2, 2021, 1:41pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988/1 "2021-02-02T13:41:19Z")

</div>

I have the following message

```auto
2021-01-04T00:04:00.8033345+00:00 0HM5E5E28610F:00000001 [INF] MyMessage

```

What I'm trying to do is to extract each of those fields into a separate column for my index.

This is what I have been using to parse the message in my pipeline

```auto
    filter {
    mutate {
      strip => "message"
    }
    grok {
      match => { "message" => "%{DATA:logdate} %{DATA:thread_id} \[%{LOGLEVEL:log.level}\] %{GREEDYDATA:message}" }
    }
    date {
      match => ["logdate", "yyyy-MM-dd HH:mm:ss.SSSSSSSZZ"]
      target => "@timestamp"
    }
}

```

At the end, I'm getting parse errors and my message ends up in Elasticsearch by sending the whole message as a column in my index. The idea is to break the 4 data I have in each line into different columns. Not only GrokParseError I receive, but also issues while converting the date.

Any idea on how to solve it?

---

<div class="post-metadata">

**Author:** ![tatdat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tatdat/32/113160_2.png) [@tatdat](https://discuss.elastic.co/u/tatdat)\
**Post date:** [February 2, 2021, 3:18pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988/2 "2021-02-02T15:18:25Z")

</div>

> [@RFeiten](#):
>
> ` %{GREEDYDATA:message}`

I think it should be worked with grok.

```auto
%{TIMESTAMP_ISO8601:action} %{NOTSPACE:thread_id} \[%{WORD:log.level}\] %{GREEDYDATA:message}

```

---

<div class="post-metadata">

**Author:** ![RFeiten](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@RFeiten](https://discuss.elastic.co/u/RFeiten)\
**Post date:** [February 2, 2021, 3:45pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988/3 "2021-02-02T15:45:01Z")

</div>

Thank you very much, it could solve the parsing issue now.  
Although, I still see 3 issues:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/0/807d78e50ce21c96d9554fb74b417e9d329b41aa.png)

1. The @logdate field shouldn't exist, as I want to replace the log entry time from the @timestamp, that means, my timestamp should be pointing to January, not the collected date;

2. The message should contain only the last field in my log entry, expected would be only "msg"

3. I see that the additional fields I added are giving me an exclamation sign that the field is not cached

Any ideas how to solve the above?

Thanks!

---

<div class="post-metadata">

**Author:** ![tatdat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tatdat/32/113160_2.png) [@tatdat](https://discuss.elastic.co/u/tatdat)\
**Post date:** [February 2, 2021, 3:52pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988/4 "2021-02-02T15:52:22Z")

</div>

(3). Go to Management, index pattern and refresh field. That is quick way. But you can index template (it look like database schema on mysql/sql).  
(2). I think no need replace "message" field. You can remove message and create new field msg  
(1). You can use date filter plugin [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)

```auto
filter {
    grok {
        match => { "message" => "%{TIMESTAMP_ISO8601:action} %{NOTSPACE:thread_id} \[%{WORD:log.level}\] %{GREEDYDATA:msg}" }
    }

    mutate {
        remove_field => ["message"]
    }
}

```

---

<div class="post-metadata">

**Author:** ![RFeiten](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@RFeiten](https://discuss.elastic.co/u/RFeiten)\
**Post date:** [February 2, 2021, 5:53pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988/5 "2021-02-02T17:53:38Z")

</div>

Thanks, that did the trick!

Best Regards.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 2, 2021, 5:54pm UTC](https://discuss.elastic.co/t/unable-to-parse-date-in-grok-and-filters/262988/6 "2021-03-02T17:54:23Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
