Last active
December 15, 2017 02:34
-
-
Save zyphlar/709a34ee67d67811372eac14423ce2bd to your computer and use it in GitHub Desktop.
Creates a Slack-compatible watcher for elastic.co cluster size
This file contains 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
curl -u admin -p -XPUT 'https://your_elasticsearch_url:9243/_watcher/watch/cluster_size_watch' -d '{ | |
"trigger" : { | |
"schedule" : { "interval" : "60s" } | |
}, | |
"input" : { | |
"http" : { | |
"request" : { | |
"host" : "your_elasticsearch_url", | |
"port" : 9243, | |
"scheme" : "https", | |
"path" : "/_stats", | |
"auth" : { | |
"basic" : { | |
"username" : "your_shield_username", | |
"password" : "your_shield_password" | |
} | |
} | |
} | |
} | |
}, | |
"condition" : { | |
"compare" : { | |
"ctx.payload._all.primaries.store.size_in_bytes" : { "gt" : 14000000000 } | |
} | |
}, | |
"actions" : { | |
"elastic_size" : { | |
"throttle_period" : "5m", | |
"webhook" : { | |
"method" : "POST", | |
"scheme" : "https", | |
"host" : "hooks.slack.com", | |
"port" : 443, | |
"path": "your_slack_hook_path", | |
"headers" : { | |
"Content-Type" : "application/json" | |
}, | |
"body" : "{\"text\": \"{{ctx.watch_id}}: Primary shard total size is {{ctx.payload._all.primaries.store.size_in_bytes}} out of 14000000000 bytes\"}" | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment