# Visualize the sum of differences of timestamps

**URL:** <https://discuss.elastic.co/t/visualize-the-sum-of-differences-of-timestamps/264708>\
**Category:** Kibana\
**Created:** [February 18, 2021, 1:45pm UTC](https://discuss.elastic.co/t/visualize-the-sum-of-differences-of-timestamps/264708 "2021-02-18T13:45:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![darefilz](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@darefilz](https://discuss.elastic.co/u/darefilz)\
**Post date:** [February 18, 2021, 1:45pm UTC](https://discuss.elastic.co/t/visualize-the-sum-of-differences-of-timestamps/264708/1 "2021-02-18T13:45:48Z")

</div>

We want to visualize the amount of time a user spend on our websites.  
Let's say each user action on such a website has a timestamp (`@timestamp`) and the name of the site (`page`) and the users name (`user`). So we term-aggregate the documents by their `user` field, sub-aggregrate by the `page` field and then… then what? We thought about max and min metrics but it does not seem possible to calculate the difference between them. We thought about serial\_diff aggregration but it is always embedded inside a histogram which is not what we want, I guess.  
Does anybody have a good idea on that topic?

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [February 18, 2021, 5:28pm UTC](https://discuss.elastic.co/t/visualize-the-sum-of-differences-of-timestamps/264708/2 "2021-02-18T17:28:00Z")

</div>

Hi @darefilz!

The use case you've described is a common case which aggregations don't do a great job of handling themselves. The best solution is really to index some additional information in something we like to call "entity-centric indexing".

Here's a video that describes entity-centric indexing, using your exact case as an example:

> **[Entity-Centric Indexing - Mark Harwood](https://www.elastic.co/videos/entity-centric-indexing-mark-harwood)**

Hope this helps!

---

<div class="post-metadata">

**Author:** ![darefilz](https://avatars.discourse-cdn.com/v4/letter/d/d07c76/32.png) [@darefilz](https://discuss.elastic.co/u/darefilz)\
**Post date:** [February 23, 2021, 3:22pm UTC](https://discuss.elastic.co/t/visualize-the-sum-of-differences-of-timestamps/264708/3 "2021-02-23T15:22:27Z")

</div>

Thanks @lukas,  
I am going to have a look at that.

---

<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 23, 2021, 3:22pm UTC](https://discuss.elastic.co/t/visualize-the-sum-of-differences-of-timestamps/264708/4 "2021-03-23T15:22:29Z")

</div>

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