ウォッチャーをインストールして条件を与えます。条件を指定しているときに、エラーが発生しました...
{"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}
動的スクリプトとは何ですか? 無効になっているというエラーが表示されます。ウォッチャーに対する私の条件は次のとおりです。
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"
}
}
}
}'