# Setting a timestamp from a JSON parsed object

**URL:** https://discuss.elastic.co/t/setting-a-timestamp-from-a-json-parsed-object/86910
**Category:** Logstash
**Created:** [May 24, 2017, 7:19am UTC](https://discuss.elastic.co/t/setting-a-timestamp-from-a-json-parsed-object/86910 "2017-05-24T07:19:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Vedran\_Maricevic](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vedran\_Maricevic](https://discuss.elastic.co/u/Vedran_Maricevic)
#### Post date: [May 24, 2017, 7:19am UTC](https://discuss.elastic.co/t/setting-a-timestamp-from-a-json-parsed-object/86910/1 "2017-05-24T07:19:03Z")

</div>

I am having an issue with setting a timestamp from a JSON parse.

I have this string (valid JSON):

> [{"orderNumber":"423523-4325-3212-4235-463a72e76fe8","externalOrderNumber":"reactivate\_22d6ff0d8f55eb821be14df9d35505a6","operation":{"name":"CAPTURE","amount":134,"status":"SUCCESS","createdAt":"2015-05-11T09:14:30.969Z","updatedAt":{}}}]

I parse it as a json using this Logstash filter:

> grok {  
> match =\> { "message" =\> "[%{GREEDYDATA:firstjson}]%{SPACE} [%{GREEDYDATA:secondjson}}]}]"}  
> }  
> json{  
> source =\> "firstjson"  
> }  
> date {  
> match =\> ["operation.createdAt", "ISO8601"]  
> }  
> mutate {  
> remove\_field =\> ["firstjson", "secondjson"]  
> }  
> }

This creates a document inside the Elasticsearch. I have a field named operation.createdAt which is properly recognised as a date field. But for some reason, this line:

> date {  
> match =\> ["operation.createdAt", "ISO8601"]  
> }

is not setting @timestamp field. Current @timestamp field is set at the moment of document insertion. What am I doing wrong?

---

<div class="post-metadata">

### Author: ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)
#### Post date: [May 28, 2017, 4:36pm UTC](https://discuss.elastic.co/t/setting-a-timestamp-from-a-json-parsed-object/86910/2 "2017-05-28T16:36:37Z")

</div>

> [@Vedran\_Maricevic](#):
>
> date {  
> match =\> ["operation.createdAt", "ISO8601"]  
> }

Try this syntax?

```auto
date {
    match => ["[operation][createdAt]", "ISO8601"]
}

```

I don't think you can use this syntax `operation.createdAt` to refer to a child field in Logstash.

---

<div class="post-metadata">

### Author: ![Vedran\_Maricevic](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@Vedran\_Maricevic](https://discuss.elastic.co/u/Vedran_Maricevic)
#### Post date: [May 29, 2017, 7:21am UTC](https://discuss.elastic.co/t/setting-a-timestamp-from-a-json-parsed-object/86910/3 "2017-05-29T07:21:17Z")

</div>

> [@anhlqn](#):
>
> match =\> ["[operation][createdAt]", "ISO8601"]

That did the trick :). Thank you

---

<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: [June 26, 2017, 7:21am UTC](https://discuss.elastic.co/t/setting-a-timestamp-from-a-json-parsed-object/86910/4 "2017-06-26T07:21:44Z")

</div>

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