Skip to content

Instantly share code, notes, and snippets.

@ilvar
Last active May 23, 2019 09:30
Show Gist options
  • Save ilvar/8b030f8a3e7f9eb014bfab11b2debdec to your computer and use it in GitHub Desktop.
Save ilvar/8b030f8a3e7f9eb014bfab11b2debdec to your computer and use it in GitHub Desktop.
Create es watch (env name is parametrized)
PUT /_watcher/watch/
{
"trigger": {
"schedule": {
"interval": "10m"
}
},
"input": {
"chain" : {
"inputs" : [
{
"vars" : {
"simple" : { "env" : "aylien-core-qa" }
}
},
{
"events" : {
"search": {
"request": {
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"match": {
"cloud.project.id.keyword": "{{ctx.payload.vars.env}}"
}
},
{
"range": {
"@timestamp": {
"gte": "now-24h"
}
}
},
{
"match": {
"newsapi_sidekiqAdmin_json.action": "indexed_clusters"
}
}
]
}
}
}
}
}}}]}
},
"condition": {
"compare" : {
"ctx.payload.events.hits.total" : {
"eq" : 0
}
}
},
"actions": {
"slack-notify": {
"throttle_period" : "4h",
"slack": {
"message": {
"to": [
"#core-alert"
],
"text": "No saved clusters in the last 4 hours for environment {{ctx.payload.vars.env}}"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment