Skip to content

Instantly share code, notes, and snippets.

#only alert on critical anomalies with a delta of (actual-typical) > X
POST _watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "5m"
}
},
"metadata": {
#chained watch for combinine anomaly scores across jobs
POST _watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "1m"
}
},
"metadata": {
@richcollier
richcollier / alert_threshold_lookup.json
Last active November 14, 2022 21:52
example watch with a lookup table of thresholds per term
POST _watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"chain": {
#==== a filtered search with one aggregation
GET filebeat-6.1.0-2017-elasticco-anon/_search
{
"size": 0,
"query": {
"bool": {
"filter": {
"range": {
"nginx.access.body_sent.bytes": {
POST _watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"search": {
#watch that counts number of anomalies and number of docs in an index
POST _xpack/watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "5m"
}
},
"metadata": {
time value
1546300800000 1
1546301100000 2
1546301400000 3
1546301700000 4
1546302000000 5
1546302300000 6
1546302600000 7
1546302900000 8
1546303200000 9
#example chain watch passing array of results
POST _xpack/watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
#record farequote watch with link to Single Metric Viewer
POST _xpack/watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "5m"
}
},
"metadata": {
#chained watch for anomalies across jobs"
POST _xpack/watcher/watch/_execute
{
"watch": {
"trigger": {
"schedule": {
"interval": "1m"
}
},
"metadata": {