Docker-Image to test elastic's Watcher-Plugin.
Thanks to Roy Russo for his elasticsearch-sample-index-Project.
git clone git@github.com:mkuenstner/docker-watcher.git
cd docker/watcher
docker build -t=watcher .
docker run -i -t -p 9200:9200 watcher
Checks the health of the cluster every 10s and alarm's if the status is red.
PUT /_watcher/watch/cluster_health_watch
{
"trigger": {
"schedule": {
"interval": "10s"
}
},
"input": {
"http": {
"request": {
"host": "localhost",
"port": 9200,
"path": "/_cluster/health"
}
}
},
"condition": {
"compare": {
"ctx.payload.status": {
"eq": "red"
}
}
},
"actions": {
"send_email": {
"email": {
"to": "root@localhost",
"subject": "Cluster Status Warning",
"body": "Cluster status is RED"
}
}
}
}
Checks the amount of documents in the comicbook-index and alarms, if less than 100 documents are present.
PUT /_watcher/watch/comicbooks
{
"trigger": {
"schedule": {
"interval": "10s"
}
},
"input": {
"http": {
"request": {
"host": "localhost",
"port": 9200,
"path": "/comicbook/_count"
}
}
},
"condition": {
"compare": {
"ctx.payload.count": {
"lte": 100
}
}
},
"actions": {
"send_email": {
"email": {
"to": "root@localhost",
"subject": "Amount of Documents in Comicbooks",
"body": "Less than 100 Docs in Index present"
}
}
}
}
Delete some documents to test the Watcher:
DELETE /comicbook/_query
{
"query": {
"wildcard": {
"name": "*n"
}
}
}
Mails are being sent to root@localhost
and can easly be viewed using mutt
.
GET /.watch_history*/_search
{
"sort" : [
{ "result.execution_time" : "desc" }
]
}
GET .watches/_search
{
"fields": [],
"query": {
"match_all": {}
}
}
DELETE /_watcher/watch/comicbooks