Skip to content

Instantly share code, notes, and snippets.

@coffeesn0b
Created January 18, 2019 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeesn0b/df8da51aefc04e25de896a598723cf5d to your computer and use it in GitHub Desktop.
Save coffeesn0b/df8da51aefc04e25de896a598723cf5d to your computer and use it in GitHub Desktop.
watcher example for k8s cluster
{
"trigger": {
"schedule": {
"interval": "3m" # run this check every 3 minutes
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"restaurant-XYZ-metrics-*" # look for any records that match this index number… each restaurant gets a unique index
],
"types": [],
"body": {
"size": 0,
"query": {
"range": {
"@timestamp": {
"gte": "now-5m" # let’s just check the last 5 minutes
}
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": { # Fire if no results are returned and execute the action
"eq": 0
}
}
},
"actions": {
"opsgenie": {
"webhook": {
"scheme": "https",
"host": "api.opsgenie.com",
"port": 443,
"method": "post",
"path": "/v1/json/eswatcher",
"params": {
"apiKey": "COWS_RULE"
},
"headers": {
"Content-Type": "application/json"
},
"body": "{{#toJson}} No metrics or logs from Restaurant XYZ. {{/toJson}}" # oh no! It’s not werkin’!
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment