Skip to content

Instantly share code, notes, and snippets.

@jeffeDivert
Last active August 26, 2016 17:57
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 jeffeDivert/7b213ae9683dc2b18c5686a50c99790c to your computer and use it in GitHub Desktop.
Save jeffeDivert/7b213ae9683dc2b18c5686a50c99790c to your computer and use it in GitHub Desktop.
PUT _watcher/watch/heartbeat_test_018
{
"trigger" : {
"schedule" : {
"interval" : "30s"
}
},
"input" : {
"search" : {
"request" : {
"indices" : "hbtest03",
"body" : {
"size" : 0,
"aggs" : {
"lastheartbeat" : {
"terms" : {
"field" : "device_no"
},
"aggs" : {
"recent_beats" : {
"top_hits" : {
"size" : 1,
"sort" : [
{
"sql_time" : {
"order" : "desc"
}
}
]
}
}
}
}
}
}
}
}
},
"condition" : {
"array_compare": {
"ctx.payload.aggregations.lastheartbeat.buckets" : {
"path": "recent_beats.hits.hits.0._source.sql_time",
"lte": {
"value": "<{now-1d}>",
"quantifier": "some"
}
}
}
},
"actions" : {
"reminder_email" : {
"email" : {
"to" : "jedwards@divertinc.com",
"subject" : "Watcher Alert",
"body" : "Test alert body. Heartbeats have stopped from one or more devices!"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment