# Identifying the stale indices in Elasticsearch

**URL:** https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537
**Category:** Elasticsearch
**Created:** [March 26, 2021, 7:46pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537 "2021-03-26T19:46:31Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![vineethsuhas](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vineethsuhas](https://discuss.elastic.co/u/vineethsuhas)
#### Post date: [March 26, 2021, 7:46pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537/1 "2021-03-26T19:46:31Z")

</div>

Hi,

I want to delete the indices which are stale (Not being accessed since last month). Is there a way to identify the indices which are not in use since one month?

I could not find any stats on the indices which corresponds to the last\_accessed\_time (Either read/write).

Just wondering if the timestamp is not maintained, but is there a way to monitor the elastic request logs to monitor the indices and delete the indices which are not used in the past month? If this is a possible solution, how to access the elastic request logs in the AWS Elasticsearch service?

Any suggestions on solving this problem would be much appreciated!

Best,  
Vineeth

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 26, 2021, 9:47pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537/2 "2021-03-26T21:47:03Z")

</div>

Welcome!

> [@vineethsuhas](#):
>
> how to access the elastic request logs in the AWS Elasticsearch service?

We don't support this service. Did you look at [Cloud by Elastic](https://www.elastic.co/cloud), also available if needed from [AWS Marketplace](https://aws.amazon.com/marketplace/pp/Elasticsearch-Inc-Elasticsearch-Service-on-Elastic/B01N6YCISK), [Azure Marketplace](https://azuremarketplace.microsoft.com/en-us/marketplace/apps/elastic.ec-azure?tab=Overview) and [Google Cloud Marketplace](https://console.cloud.google.com/marketplace/details/endpoints/elasticsearch-service.gcpmarketplace.elastic.co)?

Cloud by elastic is one way to have access to **all features** , all managed by us. Think about what is there yet like Security, Monitoring, Reporting, SQL, Canvas, Maps UI, Alerting and built-in solutions named [Observability](https://www.elastic.co/observability), [Security](https://www.elastic.co/security), [Enterprise Search](https://www.elastic.co/enterprise-search) and what is coming next 🙂 ...

> [@vineethsuhas](#):
>
> Any suggestions on solving this problem would be much appreciated!

Anyway, I don't think there's such a thing unless you activate the audit logs but this feature is not available on the service you are using I think. See [Enable audit logging | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/enable-audit-logging.html)

---

<div class="post-metadata">

### Author: ![vineethsuhas](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vineethsuhas](https://discuss.elastic.co/u/vineethsuhas)
#### Post date: [March 29, 2021, 5:34pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537/3 "2021-03-29T17:34:48Z")

</div>

Hello @dadoonet.

Thank you for the response.

I am glad to know about the Cloud by Elastic. Although it is helpful to have a completely managed Elasticsearch service, I am looking forward to the quick solution which could help me maintain my environments clean and optimize the space utilization.

Its very unfortunate to see that we are maintaining the number\_of\_queries on the index in the \_stats but not the time of the latest query. Hope to see it coming in the future releases of the Elasticsearch 🤞

Best,  
Vineeth

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 29, 2021, 6:34pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537/4 "2021-03-29T18:34:00Z")

</div>

> [@vineethsuhas](#):
>
> Hope to see it coming in the future releases of the Elasticsearch 🤞

Even if this comes in a coming version, you might not have an access to this feature as long as you are using a 3rd party service and not the official one.

That being said, how do the end users access to elasticsearch? Are they using Kibana or your own application?

---

<div class="post-metadata">

### Author: ![vineethsuhas](https://avatars.discourse-cdn.com/v4/letter/v/ac8455/32.png) [@vineethsuhas](https://discuss.elastic.co/u/vineethsuhas)
#### Post date: [March 29, 2021, 8:36pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537/5 "2021-03-29T20:36:01Z")

</div>

@dadoonet The end users use Elasticsearch through our application.

I am mostly concerned about the dev/test environments where we can create the indices in an unregulated fashion which could lead to some space utilization issues in the longer run.

I am interested in an additional statistic which can be retrieved using _index/\_stat_ to provide an additional last\_accessed\_time statistic which can help me in detecting the unused indices and delete them.

---

<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: [April 26, 2021, 8:36pm UTC](https://discuss.elastic.co/t/identifying-the-stale-indices-in-elasticsearch/268537/6 "2021-04-26T20:36:17Z")

</div>

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