Skip to content

Instantly share code, notes, and snippets.

@darkshade9
Created February 9, 2017 17:10
Show Gist options
  • Select an option

  • Save darkshade9/75df25877d150c19e4f66f2e9044ac09 to your computer and use it in GitHub Desktop.

Select an option

Save darkshade9/75df25877d150c19e4f66f2e9044ac09 to your computer and use it in GitHub Desktop.
Elasticsearch Watcher Example (Elasticsearch 5.x)
{
"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