# Date parsing logstash

**URL:** <https://discuss.elastic.co/t/date-parsing-logstash/350064>\
**Category:** Logstash\
**Created:** [December 28, 2023, 9:45am UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064 "2023-12-28T09:45:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haytham\_Shammout](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/haytham_shammout/32/119451_2.png) [@Haytham\_Shammout](https://discuss.elastic.co/u/Haytham_Shammout)\
**Post date:** [December 28, 2023, 9:45am UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064/1 "2023-12-28T09:45:38Z")

</div>

Hello Dears,

i am trying to use syslog timestamp as @timestamp in Elasticsearch, i tried to use date filter and it gives me \_dateparsefailure in the logs when i browse them on kibana.

filter Plugin snippet.

```auto
filter{
  grok{
    match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{GREEDYDATA:Server_Name} user:%{GREEDYDATA:Log_Level} IIB\[%{GREEDYDATA:id}\]: IBM Integration Bus v100014 \(%{GREEDYDATA:Node_Name}\.%{GREEDYDATA:Integration_Server}\) \[Thread %{GREEDYDATA:Thread}\] \(%{GREEDYDATA}\) %{GREEDYDATA:rest_msg}" }
  }
  grok {
        match => { "rest_msg" => "(?<bip>^.{0,8})" }
  }
  date {
         locale => "en"
         match => ["syslog_timestamp",
          "MMM d HH:mm:ss.SSS YYYY",
          "MMM dd HH:mm:ss.SSS YYYY",
          "ISO8601"]
          target => "@timestamp"
    }
}    

```

sample of log:

```auto
	**Dec 28 12:37:12** IIBV10APP01_UAT user:warn|warning IIB[3146516]: IBM Integration Bus 

```

tag:

![image](https://us1.discourse-cdn.com/elastic/original/3X/4/a/4a0b8b703502b49ab6001496c47944ec7387bfe5.png)

what should be done on the date filter to solve the issue.

Thanks.

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [December 28, 2023, 10:41am UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064/2 "2023-12-28T10:41:24Z")

</div>

For the message:

` **Dec 28 12:37:12** IIBV10APP01_UAT user:warn|warning IIB[3146516]: IBM Integration Bus`

Grok should be like this:  
`\*\*%{SYSLOGTIMESTAMP:syslog_timestamp}\*\*%{SPACE}%{DATA:Server_Name} user:%{DATA:Log_Level} IIB\[%{POSINT:id}\]: %{GREEDYDATA:rest_msg}`

- Server\_Name cannot be IPORHOST because \_ in the hostname
- Avoid GREEDYDATA because is slow, use DATA.
- Log\_Level will be `warn|warning`, I don't know is that normal, you can also split | and use LOGLEVEL instead DATA.
- You can use %{SPACE} for " ", depend on the log format.

I haven't tested,date should be like this.

```auto
 date {
         locale => "en"
         match => ["syslog_timestamp",
          "MMM d HH:mm:ss",
          "MMM dd HH:mm:ss"]
          target => "@timestamp"
    }

```

---

<div class="post-metadata">

**Author:** ![Haytham\_Shammout](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/haytham_shammout/32/119451_2.png) [@Haytham\_Shammout](https://discuss.elastic.co/u/Haytham_Shammout)\
**Post date:** [January 2, 2024, 12:38pm UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064/3 "2024-01-02T12:38:04Z")

</div>

tried to put the provided solution and there is no logs reached any more.

![image](https://us1.discourse-cdn.com/elastic/original/3X/d/b/db9ad12b421e7274b596a46581021e089d4542a5.png)

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [January 2, 2024, 2:08pm UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064/4 "2024-01-02T14:08:00Z")

</div>

Can you copy full message from debug/log or few raw lines?  
What is in the input? Beat, file or syslog? Can you put full .conf file?  
"MMM d HH:mm:ss" - use only one space like this "MMM d HH:mm:ss".

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [January 2, 2024, 9:14pm UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064/5 "2024-01-02T21:14:04Z")

</div>

```auto
input {
  generator {
       message => " **Dec 28 12:37:12** IIBV10APP01_UAT user:warn|warning IIB[3146516]: IBM Integration Bus"
	   count => 1
  }
}
filter {

   grok {
     match => { "message" => "\*\*%{SYSLOGTIMESTAMP:syslog_timestamp}\*\*%{SPACE}%{DATA:Server_Name} user:%{DATA:Log_Level} IIB\[%{POSINT:id}\]: %{GREEDYDATA:rest_msg}" }
   }

 date {
         locale => "en"
         match => ["syslog_timestamp",
          "MMM d HH:mm:ss",
          "MMM dd HH:mm:ss"]
          target => "@timestamp"
    }
	
   mutate{ remove_field => ["event", "host"] } # "@timestamp",, "event" , "message"

}
output {
 stdout { codec => rubydebug{ } }
}

```

Result:

```auto
{
          "@timestamp" => 2023-12-28T11:37:12.000Z,
                  "id" => "3146516",
         "Server_Name" => "IIBV10APP01_UAT",
            "rest_msg" => "IBM Integration Bus",
    "syslog_timestamp" => "Dec 28 12:37:12",
             "message" => " **Dec 28 12:37:12** IIBV10APP01_UAT user:warn|warning IIB[3146516]: IBM Integration Bus",
            "@version" => "1",
           "Log_Level" => "warn|warning"
}

```

---

<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:** [January 30, 2024, 9:14pm UTC](https://discuss.elastic.co/t/date-parsing-logstash/350064/6 "2024-01-30T21:14:37Z")

</div>

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