# Displaying "freshness" of available data

**URL:** <https://discuss.elastic.co/t/displaying-freshness-of-available-data/201742>\
**Category:** Kibana\
**Created:** [October 1, 2019, 7:59am UTC](https://discuss.elastic.co/t/displaying-freshness-of-available-data/201742 "2019-10-01T07:59:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniellienert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniellienert/32/31435_2.png) [@daniellienert](https://discuss.elastic.co/u/daniellienert)\
**Post date:** [October 1, 2019, 7:59am UTC](https://discuss.elastic.co/t/displaying-freshness-of-available-data/201742/1 "2019-10-01T07:59:41Z")

</div>

Hey there,

On a "meta" board, I want to visualize the "freshness" of the indexed data, meaning the age of the newest indexed document.

Currently I've done it with a scripted field per index:

```
(System.currentTimeMillis() - doc['date'].value.getMillis()) / 1000 / 60 / 60

```

and then visualize the minimum of that field.  
But that feels very bungling, as it first needs to calculate all the diffs and then get the minimum. It would feel more natural to get the max of the date field and then calculate and display the hours till now.

But how do I do this? Any help appreciated.

Thanks, Daniel

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [October 4, 2019, 11:23am UTC](https://discuss.elastic.co/t/displaying-freshness-of-available-data/201742/2 "2019-10-04T11:23:29Z")

</div>

I would do this:  
keep that scripted field.  
create a metric aggregation like this:

```auto
Metric Aggregation: Top Hit
Field: your_field
Aggregate with: concatenate
Size: 1
Sort on: date
Order: Descending

```

This should return only the latest document and it will only run that script once.

---

<div class="post-metadata">

**Author:** ![daniellienert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniellienert/32/31435_2.png) [@daniellienert](https://discuss.elastic.co/u/daniellienert)\
**Post date:** [October 4, 2019, 2:01pm UTC](https://discuss.elastic.co/t/displaying-freshness-of-available-data/201742/3 "2019-10-04T14:01:02Z")

</div>

Hey Marius,

thank you very much. I really love the elastic toolset!

Cheers,  
Daniel

---

<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:** [November 1, 2019, 2:01pm UTC](https://discuss.elastic.co/t/displaying-freshness-of-available-data/201742/4 "2019-11-01T14:01:06Z")

</div>

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