Skip to content

Instantly share code, notes, and snippets.

@w33ble
Created April 4, 2017 20:46
Show Gist options
  • Save w33ble/804cec760cb45c05b577b0e37f73dab9 to your computer and use it in GitHub Desktop.
Save w33ble/804cec760cb45c05b577b0e37f73dab9 to your computer and use it in GitHub Desktop.
reset and create watches
# A watch with only a trigger. As this watch
# has no actions there is no question of them
# ever executing.
DELETE _xpack/watcher/watch/only-trigger
PUT _xpack/watcher/watch/only-trigger
{
"trigger": {
"schedule": {
"interval": "5m"
}
}
}
POST _xpack/watcher/watch/only-trigger/_execute
{
"record_execution": true
}
# A watch with an action but no conditions or
# throttles. This watch's action will always
# execute and complete.
DELETE _xpack/watcher/watch/logger-always
PUT _xpack/watcher/watch/logger-always
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"actions": {
"log-me-something": {
"logging": {
"text": "hello there"
}
}
}
}
POST _xpack/watcher/watch/logger-always/_execute
{
"record_execution": true
}
# A watch with an action and a watch-level
# condition that will never evaluate to true.
# Ergo, this watch's action will never execute.
DELETE _xpack/watcher/watch/logger-never
PUT _xpack/watcher/watch/logger-never
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"condition": {
"never": {}
},
"actions": {
"log-me-something": {
"logging": {
"text": "hello there. You should never see me."
}
}
}
}
POST _xpack/watcher/watch/logger-never/_execute
{
"record_execution": true
}
# A watch with an action and a condition on
# that action that will never evaluate to true.
# Ergo, this watch's action will never execute.
DELETE _xpack/watcher/watch/logger-never-condition-in-action
PUT _xpack/watcher/watch/logger-never-condition-in-action
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"actions": {
"log-me-something": {
"condition": {
"never": {}
},
"logging": {
"text": "hello there. You shouldn't see me ever!"
}
}
}
}
POST _xpack/watcher/watch/logger-never-condition-in-action/_execute
{
"record_execution": true
}
# A watch with an action and a 15-minute
# throttle. Ergo, the action should only
# complete once every 15 minutes and remain
# throttled the rest of the time.
DELETE _xpack/watcher/watch/logger-always-with-throttle
PUT _xpack/watcher/watch/logger-always-with-throttle
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"actions": {
"log-me-something": {
"throttle_period": "15m",
"logging": {
"text": "hello there, I should only show up once every 15 minutes"
}
}
}
}
POST _xpack/watcher/watch/logger-always-with-throttle/_execute
{
"record_execution": true
}
POST _xpack/watcher/watch/logger-always-with-throttle/_execute
{
"record_execution": true
}
# A watch with an action but neither
# conditions nor throttles. This watch's
# action is meant to be ack'd (further
# below) so this watch's action will
# remain in an ack'd state until the
# watch is deleted and re-created.
DELETE _xpack/watcher/watch/logger-acked
PUT _xpack/watcher/watch/logger-acked
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"actions": {
"log-me-something": {
"logging": {
"text": "hello there. I should only show up until I'm acked"
}
}
}
}
POST _xpack/watcher/watch/logger-acked/_execute
{
"record_execution": true
}
POST _xpack/watcher/watch/logger-acked/_ack/log-me-something
# A watch with TWO actions but neither
# conditions nor throttles. This watch's
# FIRST action is meant to be ack'd (further
# below) so that action will remain in an
# ack'd state until the watch is deleted
# and re-created. The watch's SECOND action
# should always execute and complete.
DELETE _xpack/watcher/watch/logger-acked-and-completed
PUT _xpack/watcher/watch/logger-acked-and-completed
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"actions": {
"log-me-something": {
"logging": {
"text": "hello there. I should only show up once, until my watch is ended (deleted) and recreated"
}
},
"log-me-another-thing": {
"logging": {
"text": "hello again from the same watch. I should show up ever 5 minutes."
}
}
}
}
POST _xpack/watcher/watch/logger-acked-and-completed/_execute
{
"record_execution": true
}
POST _xpack/watcher/watch/logger-acked-and-completed/_ack/log-me-something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment