代码之家  ›  专栏  ›  技术社区  ›  TheMonkWhoSoldHisCode

使用Prometheus警报管理器使用多个度量发送警报

  •  1
  • TheMonkWhoSoldHisCode  · 技术社区  · 6 年前

    我在评估普罗米修斯的某个商业案例。我一直在遵循文件,但我没有找到一个例子来描述我的要求。

    下面是我的商业案例。

    我将泵数据(拉)到普罗米修斯与以下指标在一个拉周期。当然,在一个拉动周期中,我也可以抽取另一组完全相同的度量,但资产id将不同。

    test_value_one{asset_id="123"} 0.215
    test_value_two{asset_id="123"} 0.815
    test_value_six{asset_id="123"} 0.715
    

    我的问题是

    我可以使用多个度量(相同的资产id)构建单个规则吗。我认为可以对表达式(expr)使用多个度量。但我的要求如下。

    name: iot_rules
      rules:
      - alert: threshhold_alert
        expr: test_value >= 4
        #for: 1m
        labels:
          severity: critical     
          Additional text : The other metric values are 0.815 and 0.715
        annotations:      
          summary: 'Error detected on {{$labels.assset_id}}'
    

    0.815 0.715 需要来自其他两个指标,即 测试值2 测试值

    1 回复  |  直到 6 年前
        1
  •  0
  •   rsmoorthy    6 年前

    expr: test_value_one - test_value_two >= 4  or test_value_two - test_value_six >= 4
    

    或类似

        2
  •  0
  •   TheMonkWhoSoldHisCode    6 年前

    我的alert-manager.yml上的以下配置有助于根据asset-id聚合数据。请注意下面的“group\u by”标记。我为promwebhook公开了一个RESTAPI,从中构造了所需的文本。

    global:
    
    route:
      group_by: ['asset_id']
      group_wait: 5s
      group_interval: 5s
      repeat_interval: 2m
      receiver: node
    
    推荐文章