I installed watcher and giving the condition. While giving the condition its giving me error that...
{"error":"WatcherException[failed to put watch [log_error_watch]]; nested:
ScriptConditionValidationException[failed to compile script [return
ctx.payload.hits.total > 5] with lang [groovy] of type [INLINE]]; nested:
ScriptException[dynamic scripting for [groovy] disabled]; ","status":500}
What is dynamic scripting? Its giving me error that it is disabled. My condition to the watcher is as follows.
curl -XPUT 'http://localhost:9200/_watcher/watch/log_error_watch' -d '{
"metadata" : {
"color" : "red"
},
"trigger" : {
"schedule" : {
"interval" : "10s"
}
},
"input" : {
"search" : {
"request" : {
"search_type" : "count",
"indices" : "logs",
"body" : {
"query" : { "match" : { "status" : "error" } }
}
}
}
},
"condition" : {
"script" : "return ctx.payload.hits.total > 5"
},
"transform" : {
"search" : {
"request" : {
"indices" : "logs",
"body" : {
"query" : { "match" : { "status" : "error" } }
}
}
}
},
"actions" : {
"my_webhook" : {
"webhook" : {
"method" : "GET",
"host" : "mylisteninghost",
"port" : 9200,
"path" : "/{{watch_id}}",
"body" : "Encountered {{ctx.payload.hits.total}} errors"
}
},
"email_administrator" : {
"email" : {
"to" : "xxxxxx.xxx@gmail.com",
"subject" : "Encountered {{ctx.payload.hits.total}} errors",
"body" : "Too many error in the system, see attached data",
"attach_data" : true,
"priority" : "high"
}
}
}
}'