# Receiving below error after updating ES indices deletion script to python 3.11

**URL:** <https://discuss.elastic.co/t/receiving-below-error-after-updating-es-indices-deletion-script-to-python-3-11/368742>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [October 13, 2024, 10:59pm UTC](https://discuss.elastic.co/t/receiving-below-error-after-updating-es-indices-deletion-script-to-python-3-11/368742 "2024-10-13T22:59:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Randika\_Munasinghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/randika_munasinghe/32/138327_2.png) [@Randika\_Munasinghe](https://discuss.elastic.co/u/Randika_Munasinghe)\
**Post date:** [October 13, 2024, 10:59pm UTC](https://discuss.elastic.co/t/receiving-below-error-after-updating-es-indices-deletion-script-to-python-3-11/368742/1 "2024-10-13T22:59:47Z")

</div>

[ERROR] 2024-10-13T00:00:15.135Z 60708a75-e354-4207-96e0-24481a4a6c05 Missing 'index\_retention' in the event payload.

Code is as below

```
# Fetch all indexes
all_indexes = es.indices.get_alias("*")

# Loop through all indexes and check their creation date
for index in all_indexes:
    index_info = es.indices.get(index)
    creation_date = index_info[index]['settings']['index']['creation_date']
    
    # Convert creation date to a datetime object
    creation_date_dt = datetime.fromtimestamp(int(creation_date) / 1000.0)
    
    # Compare the creation date with the threshold date
    if creation_date_dt < threshold_date:
        print(f"Deleting index: {index}")
        # es.indices.delete(index=index)

print("Deletion complete.")

```

---

<div class="post-metadata">

**Author:** ![nfeekery](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nfeekery/32/117349_2.png) [@nfeekery](https://discuss.elastic.co/u/nfeekery)\
**Post date:** [October 15, 2024, 3:10pm UTC](https://discuss.elastic.co/t/receiving-below-error-after-updating-es-indices-deletion-script-to-python-3-11/368742/2 "2024-10-15T15:10:44Z")

</div>

Category updated on October 15, 2024, 3:10pm UTC

From #Elastic Search to #Elasticsearch

---

<div class="post-metadata">

**Author:** ![nfeekery](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nfeekery/32/117349_2.png) [@nfeekery](https://discuss.elastic.co/u/nfeekery)\
**Post date:** [October 15, 2024, 3:10pm UTC](https://discuss.elastic.co/t/receiving-below-error-after-updating-es-indices-deletion-script-to-python-3-11/368742/3 "2024-10-15T15:10:44Z")

</div>

Tags updated on October 15, 2024, 3:10pm UTC

Added #language-clients

---

<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:** [November 12, 2024, 3:11pm UTC](https://discuss.elastic.co/t/receiving-below-error-after-updating-es-indices-deletion-script-to-python-3-11/368742/4 "2024-11-12T15:11:15Z")

</div>

Closed on November 12, 2024, 3:11pm UTC

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