我想使用弹性查询在 Kibana 中创建警报。我正在使用 opendistro 警报功能。我想检查最后 10 分钟内 cpu.pct 字段的所有值是否大于 50,如果是则发出警报。
{
"size": 500,
"query": {
"bool": {
"filter": [
{
"match_all": {
"boost": 1
}
},
{
"match_phrase": {
"client.id": {
"query": "42",
"slop": 0,
"zero_terms_query": "NONE",
"boost": 1
}
}
},
{
"range": {
"cpu.pct": {
"from": 10,
"to": null,
"include_lower": true,
"include_upper": true,
"boost": 1
}
}
},
{
"range": {
"@timestamp": {
"from": "{{period_end}}||-5m",
"to": "{{period_end}}",
"include_lower": true,
"include_upper": true,
"format": "epoch_millis",
"boost": 1
}
}
}
],
"adjust_pure_negative": true,
"boost": 1
}
},
"aggregations": {
"2": {
"terms": {
"field": "client.name.keyword",
"size": 5,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": {
"_key": "desc"
}
},
"aggregations": {
"3": {
"terms": {
"field": "component.name",
"size": 1000,
"min_doc_count": 1,
"shard_min_doc_count": 0,
"show_term_doc_count_error": false,
"order": [
{
"1": "desc"
},
{
"_key": "asc"
}
]
},
"aggregations": {
"1": {
"avg": {
"field": "cpu.pct"
}
}
}
}
}
}
}
我有以下计算平均值的查询,但这是不正确的。
负例:值 (100, 100, 100, 100, 100, 100, 0, 0, 0, 0) | 发出警报:否(平均:60)
正例:值 (60, 60, 60, 60, 60, 60, 60, 60, 60, 60) | 发出警报:是(平均:60)
如何检查所有值?