Hello, I'm trying to create a watcher alert when any rabbitmq queue exceeds X amount. My query returns the results I'm looking for, but the conditional usually throws a null pointer exception. Any help is appreciated!
{
"trigger": {
"schedule": {
"interval": "5m"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"metricbeat-*"
],
"rest_total_hits_as_int": true,
"body": {
"size": 0,
"query": {
"bool": {
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-3h"
}
}
}
]
}
},
"aggs": {
"node_name": {
"terms": {
"field": "rabbitmq.node.name.keyword",
"size": "2"
},
"aggs": {
"queue_name": {
"terms": {
"field": "rabbitmq.queue.name.keyword",
"size": "100"
},
"aggs": {
"get_latest": {
"terms": {
"field": "@timestamp",
"size": 1,
"order": {
"_key": "desc"
}
},
"aggs": {
"unack_count": {
"terms": {
"field": "rabbitmq.queue.messages.unacknowledged.count"
}
}
}
}
}
}
}
}
}
}
}
}
},
"condition": {
"script": {
"source": "ArrayList arr = ctx.payload.aggregations.node_name.buckets; for (int i = 0; i < arr.length; i++) { if (arr[i]['unack_count'].value > 1) { return true; }} return false;",
"lang": "painless"
}
},
"actions": {[...]