# How to get the max timestamp of an elastic search index?

**URL:** https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513
**Category:** Elasticsearch
**Created:** [May 28, 2018, 9:55am UTC](https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513 "2018-05-28T09:55:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ranganath\_nangineni](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ranganath\_nangineni](https://discuss.elastic.co/u/ranganath_nangineni)
#### Post date: [May 28, 2018, 9:55am UTC](https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513/1 "2018-05-28T09:55:22Z")

</div>

Hi,

I have this requirement to verify the gap between logstash and elasticsearch processing .  
For this , I need to get the max timestamp of the recent index entry.

Any input from the community regrading this ?

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 28, 2018, 11:29am UTC](https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513/2 "2018-05-28T11:29:27Z")

</div>

Run a max aggregation on the @timestamp field.

---

<div class="post-metadata">

### Author: ![ranganath\_nangineni](https://avatars.discourse-cdn.com/v4/letter/r/3ec8ea/32.png) [@ranganath\_nangineni](https://discuss.elastic.co/u/ranganath_nangineni)
#### Post date: [May 28, 2018, 12:09pm UTC](https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513/3 "2018-05-28T12:09:59Z")

</div>

Thanks for the update.

The output is showing all the metadata , how can I remove the metadata just to get the required value string .  
Say 🙂

# curl -XGET "[http://localhost:9200/xyzindexpattern-\*/\_search?size=0](http://localhost:9200/xyzindexpattern-*/_search?size=0)" -H 'Content-Type: application/json' -d'

> {  
> "aggs": {  
> "max\_timestamp": {  
> "max": {  
> "field": "@timestamp"  
> }  
> }  
> }  
> }'  
> {"took":171,"timed\_out":false,"\_shards":{"total":135,"successful":135,"skipped":0,"failed":0},"hits":{"total":15841418,"max\_score":0.0,"hits":},"aggregations":{"max\_timestamp":{"value":1.527507651411E12,"value\_as\_string":"2018-05-28T11:40:51.411Z"}}}

in this I just need only " **2018-05-28T11:40:51.411Z**" should be displayed as the output.

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [May 28, 2018, 2:16pm UTC](https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513/4 "2018-05-28T14:16:25Z")

</div>

I think you will need to parse it out from that response.

---

<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: [June 25, 2018, 2:16pm UTC](https://discuss.elastic.co/t/how-to-get-the-max-timestamp-of-an-elastic-search-index/133513/5 "2018-06-25T14:16:33Z")

</div>

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