我想根据一条规则来提醒普罗米修斯,该规则用简单的英语会读到类似的内容
<div class="container">
<div class="row text-center text-lg-left">
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/pWkk7iiCoDM/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail " id="myImg" src="https://source.unsplash.com/aob0ukAYfuI/400x300" alt="">
</a>
</div>
<div id="myModal" class="modal">
<span class="close">×</span>
<img class="modal-content" id="img01">
<div id="caption"></div>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/EUfxH-pze7s/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/M185_qYH8vg/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/sesveuG_rNo/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/AvhMzHwiE_0/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/2gYsZUmockw/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/EMSDtjVHdQ8/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/8mUEy0ABdNE/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/G9Rfc1qccH4/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/aJeH0KcFkuc/400x300" alt="">
</a>
</div>
<div class="col-lg-3 col-md-4 col-6">
<a href="#" class="d-block mb-4 h-100">
<img class="img-fluid img-thumbnail" src="https://source.unsplash.com/p2TQ-3Bh3Oo/400x300" alt="">
</a>
</div>
</div>
</div>
满足此规则的要求是测量以1分钟为间隔的连续数据点的下降,如果任何数据点的下降超过或等于5%,我们将发送警报。
我正在结合使用不同的记录规则来实现这一目标。我要使用的算法如下
alert if metric X has dropped once by 5% in the last 5 minutes.
如何编写第二条记录规则?我已经尝试过clip_max / min。但是我不认为那是我想要的。对我有帮助的是promQL中的if / else构造。没有时间序列查询的经验也无济于事。非常感谢您提供任何帮助。
答案 0 :(得分:0)
这应该有效:
record: metricX:idelta_ratio
expr: ((idelta(metricX{job="A"}[2m]) / (metricX{job="A"} offset 1m)) * 100)
record: metricX:idelta_ratio_le-5
expr: metricX:idelta_ratio <= bool -5
alert: MetricXDroppedBy5Percent
expr: sum_over_time(metricX:idelta_ratio_le-5[5m]) > 0
...
但是请注意,Prometheus不保证您的指标每分钟精确收集一次。或者您的规则每分钟精确评估一次。而且您正在对规则中的1m
和2m
范围进行硬编码,如果您的抓取时间间隔发生变化,则可能会以有趣的方式误操作。