Hi there!
I've been experimenting a little bit with watcher and I had a question.
Let's start with the code.
status=yellow
echo $status
curl -XPUT 'http://localhost:9200/_watcher/watch/cluster_health_watch3' -d '{
"trigger" : {
"schedule" : { "interval" : "10s" }
},
"input" : {
"http" : {
"request" : {
"host" : "localhost",
"port" : 9200,
"path" : "/_cluster/health"
}
}
},
"condition" : {
"compare" : {
"ctx.payload.status" : { "eq" : '$status' }
}
},
"actions" : {
"send_email" : {
"email" : {
"to" : "myemail@gmail.com",
"subject" : "Cluster Status Warning",
"body" : "Cluster status is YELLOW"
}
}
}
}'
As you can see, its a plain old watcher setup for emails but with a bit a tweaking. I replaced the "yellow" at ctx.payload.status next to "eq" : with '$status'
My goal here is to be able to change the values of the watcher setup using variables. I placed a $status at the top which has the value yellow. When I process this it gives me the following error.
{"error":"WatcherException[failed to put watch [cluster_health_watch3]]; nested: WatcherException[could not parse watch [cluster_health_watch3]]; nested: JsonParseException[Unrecognized token 'red': was expecting ('true', 'false' or 'null')\n at [Source: [B@4996065a; line: 16, column: 43]]; ","status":500}
So what can I do about this? Is it even possible? Thanks