Hi,
I am wondering if it is possible to have the trigger block execute multiple times. In my example below I would like to have the webhook trigger execute for each unique hostname returned from my query results (all failed logons). The example was first designed to just grab the hostname of the first record returned from my query. I have no clue how I would go about changing my watch to accomplish what I'd like to do. I'd be greatly appreciated any help/suggestions!
curl -XPUT 'http://localhost:9200/_watcher/watch/log_error_watch' -d '{
"trigger" : { "schedule" : { "interval" : "10s" } },
"input" : {
"search" : {
"request" : {
"indices" : [ "logstash-*" ],
"body" : {
"query" : {
"match" : { "tags": "ad-logon-failure" }
}
}
}
}
},
"condition" : {
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
},
"actions" : {
"my_webhook": {
"webhook": {
"method": "POST",
"host": "myhostname",
"port": 8080,
"path": "/myapp/api",
"headers" : {
"Content-Type": "application/json",
"Accept": "application/json"
},
"body": "{ \"hostName\": \"{{ctx.payload.hits.hits.0._source.message}}\", \"userId\": \"test\"}"
}
}
}
}'