Skip to content

Instantly share code, notes, and snippets.

@zyphlar
Last active December 15, 2017 02:34
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 zyphlar/709a34ee67d67811372eac14423ce2bd to your computer and use it in GitHub Desktop.
Save zyphlar/709a34ee67d67811372eac14423ce2bd to your computer and use it in GitHub Desktop.
Creates a Slack-compatible watcher for elastic.co cluster size
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