Created
January 11, 2024 13:52
-
-
Save richcollier/7c43c5847044227688aeef19498aac9e to your computer and use it in GitHub Desktop.
Capture index sizes daily
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST _watcher/watch/_execute | |
{ | |
"watch": { | |
"trigger": { | |
"schedule": { | |
"interval": "1d" | |
} | |
}, | |
"input": { | |
"http": { | |
"request": { | |
"host": "e1964ea9b74a4168a7e26c3be7bb330f.europe-west1.gcp.cloud.es.io", | |
"port": 9243, | |
"scheme": "https", | |
"path": "/_cat/indices/*,-.*", | |
"params": { | |
"format": "json", | |
"h": "index,store.size", | |
"bytes": "b" | |
}, | |
"headers": {}, | |
"auth": { | |
"basic": { | |
"username": "elastic", | |
"password": "xxx" | |
} | |
} | |
} | |
} | |
}, | |
"condition": { | |
"always": {} | |
}, | |
"actions" : { | |
"index_payload": { | |
"transform": { | |
"script": """ | |
def documents = ctx.payload.data.stream() | |
.map(hit -> [ | |
"_index": "index_sizes", | |
"index": hit.index, | |
"store.size": hit['store.size'] | |
]) | |
.collect(Collectors.toList()); | |
return [ "_doc" : documents]; | |
""" | |
}, | |
"index": { | |
"execution_time_field": "@timestamp" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
GET index_sizes/_search
will yield something like: