[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.")