In summary, I want to generate alerts when percentage disk usage of a device goes above a certain threshold. Using Beats for data collection, the documents individually look like the default System Beat. I wrote the following aggregation to get the percentage usage per device per host.
{
"query": {
"range": {
"@timestamp": {
"gte": "now-15m",
"lte": "now"
}
}
},
"aggs": {
"by_host": {
"terms": {
"field": "beat.hostname"
},
"aggs": {
"by_device": {
"terms": {
"field": "system.filesystem.device_name"
},
"aggs": {
"disk_used_pct": {
"avg": {
"field": "system.filesystem.used.pct"
}
}
}
}
}
}
}
}
How do I generate the alert for per device per host?