What I would like is to show the latest total size (2521) of all the unique servers, preferably displayed with the "metric" visualisation.
(915 + 823 + 783 = 2521)
I've tried using the Top Hit Aggregation, but that requires me to set a fixed size.
The number of servers could change by the day.
There's no way to achieve this with a regular Kibana visualization, but you could do it with Vega.
In plain english what you'll need to do is create a terms agg on the server field and then do a top_hits agg with a descending sort on @timestamp. This will give you an aggregation response with a bucket for each unique server which contains the latest document for that server (the number of unique servers is still bounded by the size param of the terms agg, but you need some upper bound to guarantee the query won't harm your cluster). You can then use Vega transforms to grab the size from each document and sum them together to get the latest total size of all unique servers.
I wrote up an example which you can see below. I'm using a slightly different data set, but just pretend clientip is server and bytes is size.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.