# Logstash: Replace @timestamp with time like this 2020-03-27T16:00:40.982652300+00:00

**URL:** <https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938>\
**Category:** Logstash\
**Created:** [March 31, 2020, 6:57pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938 "2020-03-31T18:57:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Offord](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_offord/32/65261_2.png) [@Paul\_Offord](https://discuss.elastic.co/u/Paul_Offord)\
**Post date:** [March 31, 2020, 6:57pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/1 "2020-03-31T18:57:17Z")

</div>

Hi, I need to replace the @timestamp value with a field value (called SystemTime) that looks like this:

2020-03-27T16:00:40.982652300+00:00

I have tried numerous variations of mutate gsub and the date filter but it's obvious I have no idea how to do this. Can someone please give me a steer?

Thanks and regards...Paul

---

<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:** [March 31, 2020, 8:41pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/2 "2020-03-31T20:41:45Z")

</div>

I have not tested it but try

```
date { match => ["SystemTime", "YYYY-MM-dd'T'HH:mm:ss.SSSSSSSSSZZ"] }
```

---

<div class="post-metadata">

**Author:** ![Paul\_Offord](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_offord/32/65261_2.png) [@Paul\_Offord](https://discuss.elastic.co/u/Paul_Offord)\
**Post date:** [March 31, 2020, 9:20pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/3 "2020-03-31T21:20:22Z")

</div>

> [@Badger](#):
>
> date { match =\> ["SystemTime", "YYYY-MM-dd'T'HH:mm:ss.SSSSSSSSSZZ"] }

Thanks for the quick response. I tried this and I get a "\_dateparsefailure".

---

<div class="post-metadata">

**Author:** ![Paul\_Offord](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_offord/32/65261_2.png) [@Paul\_Offord](https://discuss.elastic.co/u/Paul_Offord)\
**Post date:** [March 31, 2020, 9:27pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/4 "2020-03-31T21:27:00Z")

</div>

Actually, SystemTime appears like this in the console output:

```auto
    "SystemTime" => [
        [0] "2020-03-27T14:08:47.500000000+00:00"
    ]

```

How do I reference the array entry? I tried `"SystemTime[0]"` but this gives "Invalid FieldReference".

---

<div class="post-metadata">

**Author:** ![Paul\_Offord](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_offord/32/65261_2.png) [@Paul\_Offord](https://discuss.elastic.co/u/Paul_Offord)\
**Post date:** [March 31, 2020, 9:38pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/5 "2020-03-31T21:38:42Z")

</div>

The input data is XML. I added `force_array => false` to the XML filter parameters, which stopped SystemTime being put into a single element array and your data filter then worked fine.

Thanks for the help.

---

<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:** [March 31, 2020, 11:06pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/6 "2020-03-31T23:06:44Z")

</div>

> [@Paul\_Offord](#):
>
> How do I reference the array entry? I tried `"SystemTime[0]"` but this gives "Invalid FieldReference".

It would be "[SystemTime][0]" if you were not using force\_array =\> false.

---

<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:** [April 28, 2020, 11:06pm UTC](https://discuss.elastic.co/t/logstash-replace-timestamp-with-time-like-this-2020-03-27t1640-982652300-00-00/225938/7 "2020-04-28T23:06:47Z")

</div>

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