一个警报的值可以在警报管理器中的另一个警报的注释描述中打印。

huangapple go评论60阅读模式
英文:

value of one alert can be prnted in annotation description of another alert in Alert manager

问题

我有一个名为“sc_pcd_g2version”的警报,在AlertManager中列出。它返回值25。

我正在寻找一种方法,将这个值“25”提取并打印到AlertManager中另一个名为“sc_pcd_encryption_server”的警报的注释描述中。

请在粗体字中查看警报“sc_pcd_encryption_server”,我希望将其包含在内。要使用当前警报值,我们使用$labels.value,同样,如何提取另一个警报的值并在注释描述中打印它呢?

英文:

I have one alert "sc_pcd_g2version" listed in AlertManager. It returns value 25.

I am looking for a way to pull this value "25" and print it into the annotation description of another alert "sc_pcd_encryption_server" in Alert manager.

See in the alert sc_pcd_encryption_server you can see in Bold letter that i am looking for to be included. To use Current alert value we use $labels.value likewise how to pull value of another alert and print it in annotation description?

name: sc_pcd_g2version
expr: sc_pcd_g2version > 0
for: 1m
labels:
  job: node
  severity: warning
annotations:
  message: Possibility of pcd g2version failure {{ $labels.instance }}.
  summary: pcd g2version Check failure


name: sc_pcd_encryption_server
expr: sc_pcd_encryption_server > 0
for: 1m
labels:
  job: node
  severity: warning
annotations:
  message: Possibility of **sc_pcd_g2version "25"** in encryption server failure {{ $labels.instance }}.
  summary: pcd encryption server Check failure

答案1

得分: 0

通常情况下,这是不可能的。

但在您的确切情况下,您可以利用一个小技巧:在您的第二个警报中,使用 sc_pcd_g2version > 0 and on(instance) sc_pcd_encryption_server > 0 而不是表达式。

这样,当使用 {{ $value }} 时,您将获得 sc_pcd_g2version 的值,而不是 sc_pcd_encryption_server 的值。

类似这样:

name: sc_pcd_encryption_server
expr: sc_pcd_g2version > 0 and on(instance) sc_pcd_encryption_server > 0
for: 1m
labels:
  job: node
  severity: warning
annotations:
  message: 可能出现 {{ $value }} 的情况,加密服务器故障 {{ $labels.instance }}。
  summary: pcd加密服务器检查故障

这是可能的,因为您没有使用 sc_pcd_encryption_server 的标签,除了 instance,而我认为它们对两个指标都是相同的。

请确保 instance 足够匹配到指标。如果不够,请在 on 子句中添加所需的标签。

英文:

Generally, this is not possible.

But in your exact case you could utilize a little trick: use sc_pcd_g2version > 0 and on(instance) sc_pcd_encryption_server > 0 instead of expression in your second alert.

That way when using {{ $value }}, you get value of sc_pcd_g2version and not sc_pcd_encryption_server.

Something like this:

name: sc_pcd_encryption_server
expr: sc_pcd_g2version > 0 and on(instance) sc_pcd_encryption_server > 0
for: 1m
labels:
  job: node
  severity: warning
annotations:
  message: Possibility of {{ $value }} in encryption server failure {{ $labels.instance }}.
  summary: pcd encryption server Check failure

This is possible because you don't use labels of sc_pcd_encryption_server, other than instance, and they will be same for both metrics I believe.

Be sure to check that instance is enough to match to metrics. If not, add needed labels to on clause.

huangapple
  • 本文由 发表于 2023年3月31日 23:55:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/75900518.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定