# Sorting events with identical timestamps by order events were recorded

**URL:** https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318
**Category:** Kibana
**Created:** [June 29, 2017, 4:34pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318 "2017-06-29T16:34:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ld\_pvl](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@ld\_pvl](https://discuss.elastic.co/u/ld_pvl)
#### Post date: [June 29, 2017, 4:34pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318/1 "2017-06-29T16:34:31Z")

</div>

Hi Elastic Team,

My question is similar to [this topic](https://discuss.elastic.co/t/order-of-logs-with-same-timestamp/28577).

For documents with identical timestamps, can we sort them on kibana by the order the events/docs were recorded? Basically I want the log lines shown on Kibana to be in the same order as I would see them in the actual log files.

Cheers,

---

<div class="post-metadata">

### Author: ![ld\_pvl](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@ld\_pvl](https://discuss.elastic.co/u/ld_pvl)
#### Post date: [June 30, 2017, 10:04am UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318/2 "2017-06-30T10:04:55Z")

</div>

Hi Elastic Team, any suggestions please?

---

<div class="post-metadata">

### Author: ![ld\_pvl](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@ld\_pvl](https://discuss.elastic.co/u/ld_pvl)
#### Post date: [July 3, 2017, 10:12am UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318/3 "2017-07-03T10:12:06Z")

</div>

After some searches, it looks like there's nothing out of the box provided by logstash nor elasticsearch and one need to come up with an own way of generating a sequence ID and adding that to the event it seems.

---

<div class="post-metadata">

### Author: ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)
#### Post date: [July 3, 2017, 4:39pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318/4 "2017-07-03T16:39:23Z")

</div>

Hi @ld_pvl,

unfortunately you are correct. Due to the facts that Elasticsearch is inherently distributed and most indexing pipelines include multiple potentially buffering stages, preserving order with a low timestamp resolution is very difficult. The best solution I can think of is to add you own sequence id during ingestion and use the [context view](https://www.elastic.co/guide/en/kibana/current/document-context.html) that was added in 5.4. If you set the `context:tieBreakerFields` setting to that sequence id field as suggested in the documentation, the context view should display the lines in the correct order.

---

<div class="post-metadata">

### Author: ![ld\_pvl](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@ld\_pvl](https://discuss.elastic.co/u/ld_pvl)
#### Post date: [July 5, 2017, 3:24pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318/5 "2017-07-05T15:24:55Z")

</div>

Thanks a lot for your reply!

The context view tip is very useful.

---

<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 2, 2017, 3:25pm UTC](https://discuss.elastic.co/t/sorting-events-with-identical-timestamps-by-order-events-were-recorded/91318/6 "2017-08-02T15:25:09Z")

</div>

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