I'm trying to create a watcher that monitors the size of a specific index. I have daily indices with this naming convention: "indexname-YYYY.MM.dd", example: "test-index-2022.01.03".
I want to monitor the size of that specific index every hour, if it grows more than 50 gigabytes, Elasticsearch must notify. To be honest, I am not 100% sure if this can be done using ML or any other technology, I am trying to do it using Watchers.
The problem is that I can't specify an static date in the watcher, I need to do it dynamically to match the current date of execution.
So I have something like this:
{
"trigger": {
"schedule": {
"interval": "60m"
}
},
"input": {
"http": {
"request": {
"host" : "hostname",
"port" : 9200,
"path" : "/test-index-{{ctx.trigger.triggered_time}}/_stats/store",
"auth" : {
"basic" : {
"username" : "user",
"password" : "password"
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload._all.total.store.size_in_bytes": {
"gte": "53687091200"
}
}
},
"actions": {
"my-logging-action": {
"logging": {
"text": "Alert message here..."
}
}
}
}
The problem is in this specific section:
"path" : "/test-index-{{ctx.trigger.triggered_time}}/_stats/store",
It gives me the time with milliseconds and other stuff, is there any way to get only the date. I don't need what is in bold below, and the date should be formatted separated by dot, not dash:
test-index-2022-01-03T23:49:00.275285Z
I think some kind of script would help, but I couldn't find any way to make it work on the input-http section
Thanks!