# How to insert timestamps in applications that use Elastic in their logging architecture?

**URL:** <https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [July 2, 2020, 5:49pm UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689 "2020-07-02T17:49:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TejaV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejav/32/71553_2.png) [@TejaV](https://discuss.elastic.co/u/TejaV)\
**Post date:** [July 2, 2020, 5:49pm UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/1 "2020-07-02T17:49:23Z")

</div>

Hi,

I want to understand the proper or the right way to insert timestamps in log messages. Is it good policy to rely on docker or k8s to take care of my log timestamps or is it a good practise to design applications/instrumented libraries to insert my defined log format which includes time field.

At the moment, with a multi-threaded application, I am unable to sort logs in order. All the log messages from different threads end-up showing the same time. I would like to log them with precise information, maybe include nanoseconds if needed.

Thanks,  
Teja

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 6, 2020, 11:05pm UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/2 "2020-07-06T23:05:55Z")

</div>

Welcome to our community! 😃

In my opinion; If you want specific precision, you'd be best off defining that in your code so you always know it's there.

---

<div class="post-metadata">

**Author:** ![TejaV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejav/32/71553_2.png) [@TejaV](https://discuss.elastic.co/u/TejaV)\
**Post date:** [July 7, 2020, 7:57am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/3 "2020-07-07T07:57:35Z")

</div>

Thanks Mark!

So, you suggest to construct my own timestamp in the code instead of relying on infrastructure.

But in general, do we see logging as the troubleshooting mechanism for such precise debugging or is it tracing or something else?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 7, 2020, 7:58am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/4 "2020-07-07T07:58:57Z")

</div>

If you can, both will be useful.

---

<div class="post-metadata">

**Author:** ![TejaV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejav/32/71553_2.png) [@TejaV](https://discuss.elastic.co/u/TejaV)\
**Post date:** [July 7, 2020, 7:59am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/5 "2020-07-07T07:59:53Z")

</div>

Also, what about the support in Elastic components?

- Does all of them support?
- Do we see any performance issues with such ingestion and querying?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 7, 2020, 8:02am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/6 "2020-07-07T08:02:03Z")

</div>

Support what sorry?

---

<div class="post-metadata">

**Author:** ![TejaV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tejav/32/71553_2.png) [@TejaV](https://discuss.elastic.co/u/TejaV)\
**Post date:** [July 7, 2020, 8:02am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/7 "2020-07-07T08:02:30Z")

</div>

I mean to say, if a service has log messages with nano second precision. Can we ingest them in Elasticsearch? Does querying and sorting of these messages consume extra resources and time?

I am also thinking about compliance to general logging RFCs. Can we mark them as compliant by introducing nano seconds?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 16, 2020, 1:32am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/8 "2020-07-16T01:32:30Z")

</div>

Yes, Elasticsearch supports [nanosecond dates](https://www.elastic.co/guide/en/elasticsearch/reference/current/date_nanos.html).

---

<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:** [August 13, 2020, 1:32am UTC](https://discuss.elastic.co/t/how-to-insert-timestamps-in-applications-that-use-elastic-in-their-logging-architecture/239689/9 "2020-08-13T01:32:37Z")

</div>

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