# Logstash Date Filter, UNIX date format parse error, date is malformed

**URL:** https://discuss.elastic.co/t/logstash-date-filter-unix-date-format-parse-error-date-is-malformed/63647
**Category:** Logstash
**Created:** [October 21, 2016, 8:06pm UTC](https://discuss.elastic.co/t/logstash-date-filter-unix-date-format-parse-error-date-is-malformed/63647 "2016-10-21T20:06:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Dark\_Light](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@Dark\_Light](https://discuss.elastic.co/u/Dark_Light)
#### Post date: [October 21, 2016, 8:06pm UTC](https://discuss.elastic.co/t/logstash-date-filter-unix-date-format-parse-error-date-is-malformed/63647/1 "2016-10-21T20:06:27Z")

</div>

I am trying to parse the Unix date from Squid logs with the Date plugin using UNIX date format. The date does not convert and there are errors in the Logstash log stating the date is malformed at the last number in the date string. I have verified the date is correct and parses correctly with external web time converters. I have tested the message with the Grok pattern in the Grok debugger and everything works as expected.

Any help on this would be greatly appreciated  
Thank you  
Rick

**This is the error message:**  
{:timestamp=\>"2016-10-21T12:33:07.780000-0700", :message=\>"Failed parsing date from field", :field=\>"timestamp", :value=\>"1477078382", :exception=\>"Invalid format: "1477078382" is malformed at "2"", :config\_parsers=\>"yyyy-MM-dd'T'HH:mm:ss.SSSSSS+HH:mm", :config\_locale=\>"default=en\_US", :level=\>:warn}

**This is the message from the Squid Log:**  
1477078382.596 103 192.168.5.184 TCP\_REFRESH\_UNMODIFIED/304 350 GET [http://data.cnn.com/jsonp/breaking\_news/domestic.json](http://data.cnn.com/jsonp/breaking_news/domestic.json)? - HIER\_DIRECT/23.59.189.98 application/javascript

**This is my Filter config:**  
#208 Squid Proxy filter  
filter {  
if [type] == "squid\_log" {  
grok {  
match =\> {"message" =\> "%{POSINT:timestamp}.%{POSINT:timestamp\_ms}\s+%{NUMBER:response\_time}\s+%{IPORHOST:user} %{WORD:result}/%{NUMBER:status\_codes} %{NUMBER:transfer\_size} %{WORD:request\_method} (?=%{NOTSPACE:request\_url})((?:(http://)%{IPORHOST:domain}(?::%{POSINT:port})?)(?:|%{URIPATH:url\_path})(?:|%{URIPARAM:url\_querystring})) (?:-|%{NOTSPACE:client\_identity}) %{WORD:peering\_code}/(?:-|%{NOTSPACE:peerhost}) (?:-|%{NOTSPACE:content\_type})"}  
}  
if "\_grokparsefailure" in [tags] {  
drop { }  
}  
}  
date {  
match =\> ["timestamp", "UNIX"]  
}

Tested the time stamp and as shown below it converts properly. I cannot recreate the malformed date error outside of Logstash.

Timestamp Converter - [http://www.unixtimestamp.com/index.php](http://www.unixtimestamp.com/index.php)

1477078382.596

```
    Is equivalent to:

```

10/21/2016 @ 7:33pm (UTC)  
2016-10-21T19:33:02+00:00 in ISO 8601  
Fri, 21 Oct 2016 19:33:02 +0000 in RFC 822, 1036, 1123, 2822  
Friday, 21-Oct-16 19:33:02 UTC in RFC 2822  
2016-10-21T19:33:02+00:00 in RFC 3339

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [October 23, 2016, 5:07pm UTC](https://discuss.elastic.co/t/logstash-date-filter-unix-date-format-parse-error-date-is-malformed/63647/2 "2016-10-23T17:07:39Z")

</div>

Works fine for me:

```nohighlight
$ cat test.config 
input { stdin { } }
output { stdout { codec => rubydebug } }
filter {
  grok {
    match => {
      "message" => "%{POSINT:timestamp}.%{POSINT:timestamp_ms}"
    }
  }
  date {
    match => ["timestamp", "UNIX"]
  }
}
$ echo '1477078382.596 103 192.168.5.184 TCP_REFRESH_UNMODIFIED/304 350 GET http://data.cnn.com/jsonp/breaking_news/domestic.json? - HIER_DIRECT/23.59.189.98 application/javascript' | logstash -f test.config
Settings: Default pipeline workers: 8
Pipeline main started
{
         "message" => "1477078382.596 103 192.168.5.184 TCP_REFRESH_UNMODIFIED/304 350 GET http://data.cnn.com/jsonp/breaking_news/domestic.json? - HIER_DIRECT/23.59.189.98 application/javascript",
        "@version" => "1",
      "@timestamp" => "2016-10-21T19:33:02.000Z",
            "host" => "bertie",
       "timestamp" => "1477078382",
    "timestamp_ms" => "596"
}
Pipeline main has been shutdown
stopping pipeline {:id=>"main"}

```

---

<div class="post-metadata">

### Author: ![Dark\_Light](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@Dark\_Light](https://discuss.elastic.co/u/Dark_Light)
#### Post date: [October 24, 2016, 4:09pm UTC](https://discuss.elastic.co/t/logstash-date-filter-unix-date-format-parse-error-date-is-malformed/63647/3 "2016-10-24T16:09:32Z")

</div>

Magnus, Thank you for validating this.

What I do not understand is why if this is successful, the Logstash.log file is filling up with date parsing errors, and I have a tag inserted of "\_dateparsefailure". I posted the error message at the beginning of this thread. The interesting thing is that the error log indicates the last character of the UNIX time stamp is malformed, yet I cannot identify anything malformed in the date data being parsed.

I doubt this matters, but I am using filebeat as the data shipper to logstash.

Thank you,  
Rick

---

<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: [July 6, 2017, 4:33am UTC](https://discuss.elastic.co/t/logstash-date-filter-unix-date-format-parse-error-date-is-malformed/63647/4 "2017-07-06T04:33:00Z")

</div>


