(v2.2 watcher ES) Convert complete payload to json to send via webhook


(Pransh) #1

HI @spinscale

Please help me with this
i am using watcher 2.2 with es 2.2.0

Cannot upgrade, complete setup is in this version

I want to send the entire payload in the json format via webhook so that python can recieve it in the json object at the other end, i am using it with basic cluster health example but not able to convert the payload to json format

"condition" : {
"compare" : {
"ctx.payload.status" : { "eq" : "red" }
"transform" : {
"script" : "return [ body: groovy.json.JsonOutput.toJson(ctx.payload.hits.hits)]"
"actions" : {
"my_webhook" : {
"webhook" : {
"scheme" : "http",
"method" : "POST",
"headers" : {
"Content-Type" : "application/json"
"host" : "hostnamet",
"port" : 1234,
"path": "/try",
"body" : "data: {{ctx.payload.body}}"

help me with this

(Pransh) #3

Done, was sending in wrong format in body.

(Alexander Reelsen) #4


as the groovy version used in elasticsearch is not containing that JsonOutput class, you cannot call it either. You would either need to create that JSON manually in the output, but I highly urge you to upgrade to 2.4, so you wont have any problems using the {{#toJson}} mustache directive.


(system) #5