Displaying "freshness" of available data

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

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

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.

1 Like

Hey Marius,

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


1 Like

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