【发布时间】:2015-06-26 13:35:25
【问题描述】:
我安装了观察者并给出了条件。在给出条件时,它给了我一个错误......
{"error":"WatcherException[failed to put watch [log_error_watch]]; nested:ScriptConditionValidationException[failed to compile script [returnctx.payload.hits.total > 5] with lang [groovy] of type [INLINE]]; nested:ScriptException[dynamic scripting for [groovy] disabled]; ","status":500}
什么是动态脚本?它给我的错误是它被禁用了。 我对观察者的条件如下。
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"
}
}
}
}'
【问题讨论】:
标签: groovy elasticsearch scripting mailing elasticsearch-watcher