I have created a watcher on packetbeat which sends email when http.code goes at or above 10 in the last 1 minute.
{
"trigger" : { "schedule" : { "interval" : "10s" } },
"input" : {
"search" : {
"request" : {
"indices" : [ "packetbeat-*" ],
"body" : {
"query" : {
"bool" : {
"must" : [
{
"match" : { "beat.hostname" : "pp-pp" }
},
{
"match" : { "http.code" : 404 }
}
],
"filter" :{
"range" : {
"@timestamp" : {
"gte" : "now-1m",
"lte" : "now"
}
}
}
}
}
}
}
}
},
"condition" : {
"compare" : { "ctx.payload.hits.total" : { "gte" : 10 }}
},
"actions" : {
"email_admin" : {
"email": {
"to": ["aviral.srivastava@company.com"],
"subject": "AppMon2.0: Application Test down!!!",
"body": "Dear user, It is found that the application Test have more than or equal to 10 http status error codes. Take a look at it."
}
}
}
}
I acknowledge watch like this:-
http://localhost:9200/_watcher/watch/packetbeat_watcher/_ack
According to my understanding of ACK Watch API, it prevents the execution of action[sending email] more than once until the condition remains satisfied.
My question is when I am acknowledging the watch just after watch creation.then also I am getting repeated emails.
But when I am acknowledging the watch when the condition turns to true. then I get only one email. But in this scenario too, when the condition turns to false then true again. Then again I am getting multiple emails.
So, when can we acknowledge the watch and do we need to acknowledge the watch again and again. everytime the watch condition turns true just after it was false.