# Serial difference of timestamps between documents

**URL:** https://discuss.elastic.co/t/serial-difference-of-timestamps-between-documents/173318
**Category:** Elasticsearch
**Created:** [March 21, 2019, 1:37pm UTC](https://discuss.elastic.co/t/serial-difference-of-timestamps-between-documents/173318 "2019-03-21T13:37:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nandrik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nandrik/32/39951_2.png) [@nandrik](https://discuss.elastic.co/u/nandrik)
#### Post date: [March 21, 2019, 1:37pm UTC](https://discuss.elastic.co/t/serial-difference-of-timestamps-between-documents/173318/1 "2019-03-21T13:37:44Z")

</div>

I'm trying to calculate the time difference between two specific types of messages coming out of Logstash. I've read the post: [Calculate the time difference between consecutive documents](https://discuss.elastic.co/t/calculate-the-time-difference-between-consecutive-documents/128282) and I've successfully implemented a ruby script in my logstash filter configuration that achieves that.

However, I wonder if all of this could have been achieved with an aggregation query within Kibana.  
Which is the most efficient way of doing this?  
By adding to Logstash's filter configuration, I have the feeling that I'm doing something wrong, adding meta information at that time.

---

<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 18, 2019, 1:37pm UTC](https://discuss.elastic.co/t/serial-difference-of-timestamps-between-documents/173318/2 "2019-04-18T13:37:50Z")

</div>

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