Elasticsearch Index Latency Rate - API

Hi, I asked a very similar question yesterday in regard to exposing Elasticsearch Indexing Rate via the API. Thanks to @danielmitterdorfer this was achieved easily.

I'm now trying to get other monitoring metrics via the Elasticsearch API, specifically the Indexing Latency. I'll also be looking into Search Rate and Search Latency too.

I've read an article online that suggests this is achievable using index_total and index_time_in_millis although doesn't say how to achieve this with these metrics. Can anybody assist wit this please?

Thanks!

For anyone who comes across this in future I've managed to calculate this figure by doing the following:

index_total: 5710707782
index_time_in_millis: 3911407200

sleep 5s

index_total: 5710893851
index_time_in_millis: 3911417418

5710893851-5710874543=19308
3911417418-3911407200=10218

10218/19308=0.529

Which roughly matches what we are seeing in Kibana for the indexing latency in ms. So the above gives us a rough indication of the last 5 seconds indexing latency. Changing the "sleep" duration will change the time bucket interval.

I'm going to go ahead and mark this as the accepted solution unless someone offers an alternative