# Actual Timestamp should be filtered from message context

**URL:** <https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258>\
**Category:** Logstash\
**Created:** [March 12, 2020, 6:24am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258 "2020-03-12T06:24:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lohit18](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lohit18/32/64131_2.png) [@lohit18](https://discuss.elastic.co/u/lohit18)\
**Post date:** [March 12, 2020, 6:24am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/1 "2020-03-12T06:24:28Z")

</div>

Dear Team,

Kindly help me with this how to do

{  
"\_index": "env-2020.03.09",  
"\_type": "\_doc",  
"\_id": "dsfhdsj2e630",  
"\_version": 1,  
"\_score": null,  
"\_source": {  
"type": "Monitor Logs",  
"host": "efjf4323",  
"message": "2020-03-08 08:55:12,415 localq-stats-0 INFO [c.a.j.c.distribution.localq.LocalQCacheManager] ",  
"@timestamp": "2020-03-09T10:28:56.460Z",  
"@version": "1"

},  
"fields": {  
"@timestamp": [  
"2020-03-09T10:28:56.460Z"  
]  
},  
"sort": [  
1583749736460  
]  
}

---

<div class="post-metadata">

**Author:** ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)\
**Post date:** [March 12, 2020, 7:44am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/2 "2020-03-12T07:44:37Z")

</div>

Hi

If you want to capture the date (or any other field) from your `message`, you'll need to parse your `message`. You can use the `grok{}` filter.

Could you please post

- your pipeline code,
- a sample of your input
- and a sample of your expected output

so we can better help you?

Please, use the "\</\>" tool to format your code, samples, etc.

Thank you

---

<div class="post-metadata">

**Author:** ![lohit18](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lohit18/32/64131_2.png) [@lohit18](https://discuss.elastic.co/u/lohit18)\
**Post date:** [March 12, 2020, 7:54am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/3 "2020-03-12T07:54:09Z")

</div>

Sure @ITIC . Kindly find Below sample json format

{  
"\_index": "env-2020.03.09",  
"\_type": "\_doc",  
"\_id": "dsfhdsj2e630",  
"\_version": 1,  
"\_score": null,  
"\_source": {  
"type": "Monitor Logs",  
"host": "efjf4323",  
"message": "2020-03-08 08:55:12,415 localq-stats-0 INFO [c.a.j.c.distribution.localq.LocalQCacheManager] ",  
"@timestamp": "2020-03-09T10:28:56.460Z",  
"@version": "1"

},  
"fields": {  
"@timestamp": [  
"2020-03-09T10:28:56.460Z"  
]  
},  
"sort": [  
1583749736460  
]  
}

Thanks for the Support !

---

<div class="post-metadata">

**Author:** ![lohit18](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lohit18/32/64131_2.png) [@lohit18](https://discuss.elastic.co/u/lohit18)\
**Post date:** [March 12, 2020, 7:58am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/4 "2020-03-12T07:58:52Z")

</div>

From the Above JSON format , need to extract Timestamp from Message and replace it with actual  
**@timestamp** in logstash config file

---

<div class="post-metadata">

**Author:** ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)\
**Post date:** [March 12, 2020, 8:07am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/5 "2020-03-12T08:07:39Z")

</div>

Great, thank you.

I´m not sure I understand what you need to do. You need to overwrite a field you extract from your `message` with `logstash`'s `@timestamp`? Why not use the `@timestamp` field itself where needed, instead? I´m afraid I must have misunderstood you.

Now, could you please post

- your pipeline code,
- and a sample of your expected output

so we can better help you?

Please, use the "\</\>" tool to format your code, samples, etc.

Thank you

---

<div class="post-metadata">

**Author:** ![lohit18](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lohit18/32/64131_2.png) [@lohit18](https://discuss.elastic.co/u/lohit18)\
**Post date:** [March 12, 2020, 8:10am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/6 "2020-03-12T08:10:56Z")

</div>

Welcome !

My Input Data which I am receiving is  
{  
"\_index": "env-2020.03.09",  
"\_type": "\_doc",  
"\_id": "dsfhdsj2e630",  
"\_version": 1,  
"\_score": null,  
"\_source": {  
"type": "Monitor Logs",  
"host": "efjf4323",  
"message": "2020-03-08 08:55:12,415 localq-stats-0 INFO [c.a.j.c.distribution.localq.LocalQCacheManager] ",  
"@timestamp": "2020-03-09T10:28:56.460Z",  
"@version": "1"

},  
"fields": {  
"@timestamp": [  
"2020-03-09T10:28:56.460Z"  
]  
},  
"sort": [  
1583749736460  
]  
}

Output Should be Like this  
{  
"\_index": "env-2020.03.09",  
"\_type": "\_doc",  
"\_id": "dsfhdsj2e630",  
"\_version": 1,  
"\_score": null,  
"\_source": {  
"type": "Monitor Logs",  
"host": "efjf4323",  
**"message": "2020-03-08 08:55:12** ,415 localq-stats-0 INFO [c.a.j.c.distribution.localq.LocalQCacheManager] ",  
"@timestamp": "2020-03-09T10:28:56.460Z",  
"@version": "1"

},  
"fields": {  
**"@timestamp": [**  
**"2020-03-08 08:55:12"**  
**]**  
},  
"sort": [  
1583749736460  
]  
}

Kindly check Words with Bold , Easily you can identify.

Cheers,

---

<div class="post-metadata">

**Author:** ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)\
**Post date:** [March 12, 2020, 8:19am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/7 "2020-03-12T08:19:50Z")

</div>

Hi

I get it now, thank you.

To extract the date from your `message` field you can use a `grok{}` filter. Info on this filter can be found here: [https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html) and some predefined parameters are here: [https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns](https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns)

The next question is why you want to replace `logstash`'s `@timestamp`. It is not recommended (don't know exactly why, I think it has to do with the relationship with the other elements of the ELK stack) and instead you should have a new field with your time. You'll get this field directly out of the `grok{}` filter I suggested above.

Hope this helps get you started.

---

<div class="post-metadata">

**Author:** ![lohit18](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lohit18/32/64131_2.png) [@lohit18](https://discuss.elastic.co/u/lohit18)\
**Post date:** [March 12, 2020, 8:29am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/8 "2020-03-12T08:29:35Z")

</div>

Sure , i will do and can you say how to create new field(Time) and assign to extracted timestamp from message body context . if you write sample lines it really helps me

---

<div class="post-metadata">

**Author:** ![ITIC](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@ITIC](https://discuss.elastic.co/u/ITIC)\
**Post date:** [March 12, 2020, 8:33am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/9 "2020-03-12T08:33:31Z")

</div>

HI

Give it a try or five. We will be happy to help you improve your code.

---

<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 9, 2020, 8:33am UTC](https://discuss.elastic.co/t/actual-timestamp-should-be-filtered-from-message-context/223258/10 "2020-04-09T08:33:36Z")

</div>

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