为标签设置的普罗米修斯度量值设置警报

时间:2020-09-25 02:35:59

标签: monitoring prometheus prometheus-alertmanager

我是PromQL的新手,我正在尝试根据具有上一次成功备份的开始时间的指标为备份失败设置警报。我们正在使用Stash来运行备份作业,并且它导出了几个指标。我正在使用一个名为stash_backup_last_success_time_seconds的指标。我们有几个备份作业,它们每夜运行一次,不需要花费一个多小时即可完成。所以,

我构建了以下警报规则,我认为当最新即时值(最近一次成功备份时间)超过25小时时会触发警报:

(time() - max_over_time(stash_backup_target_last_success_time_seconds[36h])) > (60 * 60 * 25)

但是,我仍在尝试了解如何按特定标签对指标进行分组,以便即使其中一个备份作业的成功备份时间超过25小时也能收到警报。

例如,当我寻找超过1小时的成功备份时间时,在这里我们看到三个数据点。

{driver="Restic",endpoint="pushgateway",group="apps",invoker_kind="BackupConfiguration",invoker_name="sts-avalon",job="stash-backup",kind="StatefulSet",name="avalon",namespace="test",pod="stash-enterprise-6c666b65cf-767qf",repository="sts-avalon",service="stash-enterprise"}  5112.564659833908
{driver="Restic",endpoint="pushgateway",group="apps",invoker_kind="BackupConfiguration",invoker_name="sts-drupal-staff-blog",job="stash-backup",kind="StatefulSet",name="drupal-staff-blog",namespace="test",pod="stash-enterprise-6c666b65cf-767qf",repository="sts-drupal-staff-blog",service="stash-enterprise"} 91508.322524786
{driver="Restic",endpoint="pushgateway",group="apps",invoker_kind="BackupConfiguration",invoker_name="sts-drupal-whpool",job="stash-backup",kind="StatefulSet",name="drupal-whpool",namespace="qa",pod="stash-enterprise-6c666b65cf-767qf",repository="sts-drupal-whpool",service="stash-enterprise"}   5089.431462526321

我想按“名称”,“种类”和“名称空间”将stash_backup_target_last_success_time_seconds度量标准分组(我认为它们是组合键),以便将它们的每种组合都视为唯一流,如果这些唯一组合中的任何一个都没有成功备份,则需要提醒我。另外,我想指出,由于每次备份调用都会更改pod标签,因此应该将其忽略。

我会很感激我如何实现这一目标。

0 个答案:

没有答案