Hi everyone,
Can I create an alert that will check each agent individually for missing logs every 2 minutes? Each server runs the who command every minute and I want an alert to be generated if at least one agent stops sending logs.
I tried the Group by function on the
agent.name field, but it works only when no logs are sent from any agent (Screenshot). I also tried the DSL Query condition:
{
"query": {
"bool": {
"must": [
{
"range": {
"@timestamp": {
"gte": "now-3m/m",
"lte": "now/m"
}
}
},
{
"exists": {
"field": "@timestamp"
}
}
]
}
},
"aggs": {
"servers": {
"terms": {
"field": "
agent.name",
"size": 1000
},
"aggs": {
"missing_logs": {
"missing": {
"field": "@timestamp"
}
}
}
}
}
}
trigger conditions that I've tried:
return ctx.results[0].aggregations.metric.value == null ? false : ctx.results[0].aggregations.metric.value < 1;
and
return ctx.results[0].aggregations.servers.buckets.some(bucket => bucket.missing_logs.doc_count > 0);
But it doesn't work as well.
I hope I've made myself clear.
Thanks in advance!