Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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