kubesphere / notification-manager

K8s native notification management with multi-tenancy support
Apache License 2.0
226 stars 68 forks source link

webhook发送的body中未包含value信息 #212

Open lefreet opened 1 year ago

lefreet commented 1 year ago

问题

{
  "receiver": "prometheus",
  "status": "firing",
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alerttype": "metric",
        "namespace": "pro",
        "owner_kind": "Deployment",
        "rule_id": "pro-e5df62249c7c718b",
        "severity": "error",
        "workload": "Deployment:pro1-web-v1",
        "cluster": "default",
        "alertname": "ram"
      },
      "annotations": {
        "rules": "[{\"_metricType\":\"namespace:workload_memory_usage:sum{$1}\",\"condition_type\":\">\",\"thresholds\":\"1\",\"unit\":\"Mi\"}]",
        "summary": "Deployment pro1-web-v1 内存用量 > 1Mi",
        "aliasName": "内存占用过高",
        "kind": "Deployment",
        "message": "请及时处理\n\n# @users wsn\n# @webhook xxxxx",
        "resources": "[\"pro1-web-v1\"]",
        "rule_update_time": "2023-06-19T06:49:26Z"
      },
      "startsAt": "2023-06-19T06:51:16.65157632Z",
      "endsAt": "0001-01-01T00:00:00Z",
      "generatorURL": "/graph?g0.expr=namespace%3Aworkload_memory_usage%3Asum%7Bnamespace%3D%22pro%22%2Cworkload%3D%22Deployment%3Apro1-web-v1%22%7D+%3E+1.048576e%2B06&g0.tab=1",
      "fingerprint": "cfd8b7774964e037"
    }
  ],
  "groupLabels": {
    "alertname": "ram",
    "namespace": "pro",
    "rule_id": "pro-e5df62249c7c718b"

  },

  "commonLabels": {
    "owner_kind": "Deployment",
    "rule_id": "pro-e5df62249c7c718b",
    "severity": "error",
    "workload": "Deployment:pro1-web-v1",
    "alertname": "ram",
    "alerttype": "metric",
    "namespace": "pro"
  },
  "commonAnnotations": {
    "summary": "Deployment pro1-web-v1 内存用量 > 1Mi",
    "aliasName": "内存占用过高",
    "kind": "Deployment",
    "message": "请及时处理\n\n# @users wsn\n# @webhook xxxxxx",
    "resources": "[\"pro1-web-v1\"]",
    "rule_update_time": "2023-06-19T06:49:26Z",
    "rules": "[{\"_metricType\":\"namespace:workload_memory_usage:sum{$1}\",\"condition_type\":\">\",\"thresholds\":\"1\",\"unit\":\"Mi\"}]"
  },
  "externalURL": "http://alertmanager-main-0:9093"
}
benjaminhuo commented 1 year ago

@junotx prometheus alert rule 计算的只是一个阈值是否超限,结果类似是否告警这种二元信息,可能带上 value 的信息吗?

lefreet commented 1 year ago

@benjaminhuo 看了模板的文档, webhook 是用template 特殊序列化的(没找到具体实现),template本身有支持.Value,应该可以; 本身用grafana的另一套监控系统是支持这个机制的,应该是常规操作