Hi All,
We are using Elasticsearch watchers for getting the total data ingested from each index. But since we are having different ILMs for each index, we are not able to get the average data ingested for a particular day.
For example, the index-1 is having 7 days of ILM period, while index-2 is having 10 days of ILM. Could anyone please suggest on how to have the separate conditions for each index?
Please find the existing watcher below:
{
"trigger" : {
"schedule" : {
"interval" : "2m"
}
},
"input": {
"http": {
"request": {
"scheme": "https",
"host": "####",
"port": 9243,
"method": "get",
"path": "_cat/indices",
"params": {
"format": "yaml",
"human": "true",
"bytes": "mb"
},
"headers": {},
"auth": {
"basic": {
"username": "elastic",
"password": "***"
}
}
}
}
},
"condition": {
"script": {
"source": "return true;",
"lang": "painless"
}
},
"actions": {
"email_administrator": {
"transform": {
"script": {
"source": """
ctx.payload.total = (ctx.payload.data.stream().collect(Collectors.summarizingDouble(e -> Double.parseDouble(e['store.size']))).sum)/1024;
return ctx.payload;
""",
"lang": "painless"
}
},
"email": {
"profile": "standard",
"to": [
"myemail@abc.com"
],
"subject": "Index-wise data",
"body": {
"html": """
Index-wise data
{{#ctx.payload.data}} {{/ctx.payload.data}}
IndexName | StoreSize |
---|---|
{{index}} | {{store.size}} MB |
TOTAL STORE SIZE | {{ctx.payload.total}} GB |
"""
}
}
}
}
}