I've created some watchers to check if all communications are working in our company. This watcher should trigger when there's no hits in the pas hour.
The problem is it fires sometimes, when I run the exact same query it returns 700+ hits. Is there something wrong with this watcher, or can this happen because the hits (messages) are quite large?
ps: when I simulate the watcher, it always returns hits.
{
"trigger": {
"schedule": {
"daily": {
"at": [
{
"hour": [
8,
9,
10,
12,
14,
16,
18,
20,
22,
23
],
"minute": [
0,
30
]
}
]
}
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"_all"
],
"rest_total_hits_as_int": true,
"body": {
"query": {
"bool": {
"must": [
{
"query_string": {
"fields": [
"receiver"
],
"analyzer": "standard",
"query": "stockservice"
}
},
{
"query_string": {
"fields": [
"document"
],
"analyzer": "standard",
"query": "stock"
}
},
{
"range": {
"created_at": {
"gte": "now-1h",
"lte": "now"
}
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"eq": 0
}
}
},
"actions": {
"opsgenie": {
"webhook": {
"scheme": "https",
"host": "api.opsgenie.com",
"port": 443,
"method": "post",
"path": "/v1/json/eswatcher",
"params": {
"apiKey": "123456789"
},
"headers": {
"Content-Type": "application/json"
},
"body": "{{#toJson}}ctx{{/toJson}}"
}
}
}
}