# How to have provide value for @timestamp when using JSON?

**URL:** https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071
**Category:** Logstash
**Created:** [February 8, 2018, 2:46pm UTC](https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071 "2018-02-08T14:46:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![some7](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@some7](https://discuss.elastic.co/u/some7)
#### Post date: [February 8, 2018, 2:46pm UTC](https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071/1 "2018-02-08T14:46:31Z")

</div>

I send a JSON object string to logstash, and one of the keys of the JSON object is `@timestamp` with a timestamp I've generated, but when I put it into logstash I get `@timestamp` which is generated by logstash, and `@_timestamp` which is the value I set. How can I provide a custom timestamp value directly from the application?

Is it possible to do this without using filters or modifying the logstash config file?

---

<div class="post-metadata">

### Author: ![sachin\_frayne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sachin_frayne/32/47922_2.png) [@sachin\_frayne](https://discuss.elastic.co/u/sachin_frayne)
#### Post date: [February 8, 2018, 4:34pm UTC](https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071/4 "2018-02-08T16:34:55Z")

</div>

Use a date filter, that'll do it, 🙂

---

<div class="post-metadata">

### Author: ![sachin\_frayne](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sachin_frayne/32/47922_2.png) [@sachin\_frayne](https://discuss.elastic.co/u/sachin_frayne)
#### Post date: [February 8, 2018, 7:15pm UTC](https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071/5 "2018-02-08T19:15:40Z")

</div>

Sorry I re-read your question and now I am not sure what you mean by custom timestamp, can you please clarify? Maybe with an example?

---

<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: [February 8, 2018, 8:09pm UTC](https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071/6 "2018-02-08T20:09:37Z")

</div>

It can be done provided the @timestamp is in the right format. For example, with the logstash.conf containing

```
input { stdin { codec => "json" } }
output { stdout { codec => rubydebug } }
```

and no filters, if you feed it these two lines

```
{ "@timestamp" : "2018-02-08T11:00:00.000Z" }
{ "@timestamp" : "2018-02-08 14:56:29" }
```

then for the first one you will get

> "@timestamp" =\> 2018-02-08T11:00:00.000Z,

but for the second line you get an \_@timestamp and logstash adds it own @timestamp. So you would need to use a date filter if your @timestamp is not in the format logstash expects.

> "@timestamp" =\> 2018-02-08T20:04:37.085Z,  
> "\_@timestamp" =\> "2018-02-08 14:56:29",  
> "tags" =\> [  
> [0] "\_timestampparsefailure"  
> ]

---

<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: [March 8, 2018, 8:09pm UTC](https://discuss.elastic.co/t/how-to-have-provide-value-for-timestamp-when-using-json/119071/7 "2018-03-08T20:09:47Z")

</div>

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