Hi,
With the help from multiple discussions in this forum, I'm able to create a watcher to look for any snapshots in 'failed' state in a given snapshot repository.
{
"trigger": {
"schedule": {
"interval": "60s"
}
},
"input": {
"http": {
"request": {
"scheme": "https",
"host": "hostname",
"port": 9656,
"method": "get",
"path": "/_snapshot/repo_name/_all",
"params": {},
"headers": {},
"auth": {
"basic": {
"username": "user",
"password": "password"
}
}
}
}
},
"condition": {
"array_compare": {
"ctx.payload.snapshots": {
"path": "state",
"eq": {
"value": "FAILED"
}
}
}
},
"actions": {
"email_action": {
"transform": {
"script": {
"source": "return [ 'failed_snapshots' : ctx.payload.snapshots.stream().filter( s -> s.state == 'FAILED').collect(Collectors.toList()) ]",
"lang": "painless"
}
},
"email": {
"profile": "standard",
"priority": "high",
"to": [
"email"
],
"subject": "Snapshot Watcher Alert",
"body": {
"text": "The following Snapshots failed: {{#ctx.payload.failed_snapshots}} {{snapshot}},{{state}},{{shards}} : {{/ctx.payload.failed_snapshots}} "
}
}
}
}
}
Now, I've multiple repositories to lookout for. How can I loop through multiple repositories for failed snapshots without creating a new watcher for all my individual repos.
Is it possible to use chained input, with first input to fetch all the snapshots available and second input to fetch the snapshots with each repository using {{#ctx.payload.first}}..{{/ctx.payload.first}} ?
appreciate your thoughts/inputs.