Grafana:如何根据两个事件创建警报?
Posted
技术标签:
【中文标题】Grafana:如何根据两个事件创建警报?【英文标题】:Grafana: How create alert based on two events? 【发布时间】:2020-02-18 11:22:14 【问题描述】:如果 last_hour_mins_average_status
> 3.4 和 last_five_mins_requests_to_gateway_gauge_count
> 75 每个相同的网关,我需要创建警报。有以下输入:
# HELP last_five_mins_requests_to_gateway_gauge_count labels: gatewayId
# TYPE last_five_mins_requests_to_gateway_gauge_count gauge
last_five_mins_requests_to_gateway_gauge_countgatewayId="34" 1
last_five_mins_requests_to_gateway_gauge_countgatewayId="38" 32
last_five_mins_requests_to_gateway_gauge_countgatewayId="44" 34
last_five_mins_requests_to_gateway_gauge_countgatewayId="51" 23
last_five_mins_requests_to_gateway_gauge_countgatewayId="68" 14
last_five_mins_requests_to_gateway_gauge_countgatewayId="75" 1
last_five_mins_requests_to_gateway_gauge_countgatewayId="76" 71
last_five_mins_requests_to_gateway_gauge_countgatewayId="79" 1
和
# HELP last_hour_mins_average_status Average value by message status by last 60 minutes
# TYPE last_hour_mins_average_status gauge
last_hour_mins_average_statusgatewayId="34" 1.6923
last_hour_mins_average_statusgatewayId="38" 1.5004
last_hour_mins_average_statusgatewayId="44" 1.1569
last_hour_mins_average_statusgatewayId="51" 1.7835
last_hour_mins_average_statusgatewayId="62" 8.0000
last_hour_mins_average_statusgatewayId="68" 1.3075
last_hour_mins_average_statusgatewayId="75" 1.2727
last_hour_mins_average_statusgatewayId="76" 1.3703
last_hour_mins_average_statusgatewayId="78" 1.0000
last_hour_mins_average_statusgatewayId="79" 2.1622
我创建了查询 A:
avg_over_time(lox24_sms_last_five_mins_requests_to_gateway_gauge_count[1m])
和查询 B:
avg_over_time(lox24_sms_last_hour_mins_average_status[1m])
和警报条件(UI形式):
when avg() of query(A, 5m, now) is above 75
and avg() of query(B, 5m, now) is above 3.4
当 ANY gatewayId 的消息数 > 75 且 ANY gatewayId 的平均状态 > 3.4 时,就会发生警报。
但只有当这两种情况都发生在同一个 gatewayId 上时,我才需要提醒。
【问题讨论】:
【参考方案1】:这是应该执行此操作的 Prometheus 查询(尚未测试,但应该可以):
last_five_mins_requests_to_gateway_gauge_count > 75
and
last_hour_mins_average_status > 3.4
【讨论】:
以上是关于Grafana:如何根据两个事件创建警报?的主要内容,如果未能解决你的问题,请参考以下文章
如何配置 Grafana 以捕捉 Prometheus 指标的急剧下降?