# Dateparse failure When trying to get date from xml file

**URL:** https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342
**Category:** Logstash
**Created:** [April 16, 2020, 2:37pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342 "2020-04-16T14:37:01Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![kagashe](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kagashe](https://discuss.elastic.co/u/kagashe)
#### Post date: [April 16, 2020, 2:37pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/1 "2020-04-16T14:37:01Z")

</div>

Hi all, I'm trying to update the @timestamp field to be the timestamp pulled from my source xml file.  
The xml fields are mapped with xpath and all seem to be parsing fine however when I run the date filter below it does not parse and update the @timestamp field, where am I going wrong?

this is datetime format i'm trying to parse which is mapped to the 'time' field by the xml filter.

```auto
    2020-02-01 02:28:39.647919 +0000

```

And this is my date filter which comes after the xml filter

```auto
    filter {
      date {
          match => [
               "time",
               "yyyy-MM-dd HH:mm:ss.SSSSSSZ",
               "yyyy-MM-dd HH:mm:ss.SSSSSS Z",
               "yyyy-MM-dd HH:mm:ss.SSS Z",
               "yyyy-MM-dd HH:mm:ss.SSSZ",
               "yyyy-MM-dd HH:mm:ss.SSS",
               "yyyy-MM-dd HH:mm:ss,SSS",
               "yyyy-MM-dd HH:mm:ss"
              ]
         target => "@timestamp"
       }
    }

```

any help would be really appreciated, this is starting to do my head in.

---

<div class="post-metadata">

### Author: ![adminunix](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@adminunix](https://discuss.elastic.co/u/adminunix)
#### Post date: [April 16, 2020, 3:19pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/2 "2020-04-16T15:19:27Z")

</div>

Hello,

I think you have a lot of time formats. Try to simplify with this:

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

```

Also, according to elastic guide: [https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html)

S --\> _"fraction of a second. **Maximum precision is milliseconds ( `SSS` ). Beyond that, zeroes are appended.**"_

Regards.

---

<div class="post-metadata">

### Author: ![kagashe](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kagashe](https://discuss.elastic.co/u/kagashe)
#### Post date: [April 16, 2020, 3:47pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/3 "2020-04-16T15:47:52Z")

</div>

Hi @adminunix I have replaced my config with yours but I'm still getting the dateparse error and @timestamp is not correct, is there anything else you can think of?

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [April 16, 2020, 4:32pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/4 "2020-04-16T16:32:33Z")

</div>

If you use

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

```

what does the [time] field look like?

---

<div class="post-metadata">

### Author: ![kagashe](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kagashe](https://discuss.elastic.co/u/kagashe)
#### Post date: [April 16, 2020, 7:51pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/5 "2020-04-16T19:51:18Z")

</div>

Hi @Badger the output is as follows for the time field.

```auto
           "time" => [[0] "2020-02-16 03:25:28.529609 +0000" ],

```

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [April 16, 2020, 8:09pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/6 "2020-04-16T20:09:33Z")

</div>

OK, it is an array, so you need to reference the first element using

```
match => ["[time][0]", ...
```

---

<div class="post-metadata">

### Author: ![kagashe](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kagashe](https://discuss.elastic.co/u/kagashe)
#### Post date: [April 16, 2020, 8:17pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/7 "2020-04-16T20:17:30Z")

</div>

ok @Badger, my config is now as followsbut I'm still getting the dateparse error?

```auto
filter {
  date {
    match => ["[time][0]", "yyyy-MM-dd HH:mm:ss.SSS Z", "ISO8601" ]
    target => "@timestamp"
  }
}

```

---

<div class="post-metadata">

### Author: ![kagashe](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kagashe](https://discuss.elastic.co/u/kagashe)
#### Post date: [April 16, 2020, 8:27pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/8 "2020-04-16T20:27:38Z")

</div>

Ok i fixed it by changing to this

```auto
filter {
  date {
    match => ["[time][0]", "yyyy-MM-dd HH:mm:ss.SSSSSS Z", "ISO8601" ]
    target => "@timestamp"
  }
}

```

---

<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: [May 14, 2020, 8:27pm UTC](https://discuss.elastic.co/t/dateparse-failure-when-trying-to-get-date-from-xml-file/228342/9 "2020-05-14T20:27:44Z")

</div>

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