Created
February 9, 2017 17:10
-
-
Save darkshade9/75df25877d150c19e4f66f2e9044ac09 to your computer and use it in GitHub Desktop.
Elasticsearch Watcher Example (Elasticsearch 5.x)
This file contains hidden or 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": "60s" | |
| } | |
| }, | |
| "input": { | |
| "search": { | |
| "request": { | |
| "indices": ["indexname-*"], | |
| "body": { | |
| "query": { | |
| "bool": { | |
| "must": [{ | |
| "match": { | |
| "query": "Response.StatusCode:>399" | |
| }, | |
| "match": { | |
| "query": "Response.StatusCode:<500" | |
| } | |
| }, { | |
| "range": { | |
| "datetime": { | |
| "gte": "now-5m", | |
| "lte": "now" | |
| } | |
| } | |
| }] | |
| } | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "condition": { | |
| "compare": { | |
| "ctx.payload.hits.total": { | |
| "gte": 10 | |
| } | |
| } | |
| }, | |
| "actions": { | |
| "email_admin": { | |
| "throttle_period": "15m", | |
| "email": { | |
| "to": ["[email protected]"], | |
| "subject": "INDEXNAME - Excessive HTTP 400 Errors", | |
| "body": { | |
| "text": "In the past 5 minutes, there have been {{ctx.payload.hits.total}} HTTP 400 errors coming from INDEXNAME. See attachment for details." | |
| }, | |
| "attachments": { | |
| "attached_data": { | |
| "data": { | |
| "format": "json" | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment