watcher example for k8s cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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