searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

AlertManager设置告警静默

2024-11-29 09:12:03
4
0

1 告警静默配置

1.1 AlertManager告警配置页面

1.2 请求url

post /api/v2/silences

1.3 请求参数

{
  "matchers": [                            // 告警匹配规则
    {
      "name": "alertName",
      "value": "告警测试",
      "isRegex": false,
      "isEqual": true
    }
  ],
  "startsAt": "2023-12-28T06:22:00.000Z",  //静默开始时间
  "endsAt": "2023-12-28T08:22:00.000Z",    //静默结束时间
  "createdBy": "test",                      //静默规则由谁创建
  "comment": "告警测试",                    //静默规则说明
  "id": null
}

1.4 返回结果

{"silenceID":"dbc58962-10db-4653-88e3-a1d50eec53c9"}

2 告警静默规则详情

2.1 请求url

GET /api/v2/silence/{silenceID}

2.2 请求参数

silenceId: 创建或者更新静默规则时返回的silenceId

2.2 返回结果

{
    "id": "dbc58962-10db-4653-88e3-a1d50eec53c9",
    "status": {
        "state": "active"
    },
    "updatedAt": "2023-12-28T06:24:32.333Z",
    "comment": "告警测试",
    "createdBy": "test",
    "endsAt": "2023-12-28T08:22:00.000Z",
    "matchers": [
        {
            "isEqual": true,
            "isRegex": false,
            "name": "alertName",
            "value": "告警测试"
        }
    ],
    "startsAt": "2023-12-28T06:24:32.333Z"
}

3 告警静默规则编辑

3.1 请求url

POST /api/v2/silences

3.2 请求参数

{
  "matchers": [
    {
      "name": "alertName",
      "value": "告警测试",
      "isRegex": false,
      "isEqual": true
    },
    {
      "name": "alertId",
      "value": "1",
      "isRegex": false,
      "isEqual": true
    }
  ],
  "startsAt": "2023-12-28T06:24:32.333Z",
  "endsAt": "2023-12-28T08:22:00.000Z",
  "createdBy": "test",
  "comment": "告警测试",
  "id": "dbc58962-10db-4653-88e3-a1d50eec53c9"  //要修改的告警静默规则的silenceId
}

3.3 返回结果

{"silenceID":"122fe701-d953-4d44-8c45-e45a51607e76"}  //新的silenceId

编辑后,原静默规则过期,生成新的静默规则,返回新规则的silenceId.

4 告警静默规则过期

4.1 请求方法

DELETE /api/v2/silence/{silenceId}

4.2 请求参数

silenceId: 创建或者更新静默规则时返回的silenceId

4.3 返回结果

5 查询告警静默规则列表

5.1 请求方法

GET /api/v2/silences?silenced=false&inhibited=false&active=true

5.2 请求参数

silenced:

inhibited:

active:

5.3 返回结果

[
  {
    "id": "4d1bd45b-ff7d-4a4f-ab17-9e552656121b",
    "status": {
      "state": "active"
    },
    "updatedAt": "2024-01-02T09:40:14.955Z",
    "comment": "告警静默测试",
    "createdBy": "test",
    "endsAt": "2024-01-02T11:18:06.560Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "outProdInstId",
        "value": "653eaac1b58b40ab8a087c9898f285c8"
      },
      {
        "isEqual": true,
        "isRegex": false,
        "name": "alertStrategyId",
        "value": "474"
      }
    ],
    "startsAt": "2024-01-02T09:40:14.955Z"
  },
  {
    "id": "a44fb62c-2c9b-404d-81b7-19579e0afe8a",
    "status": {
      "state": "expired"
    },
    "updatedAt": "2024-01-02T09:40:14.955Z",
    "comment": "告警静默测试",
    "createdBy": "test",
    "endsAt": "2024-01-02T09:40:14.955Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "outProdInstId",
        "value": "653eaac1b58b40ab8a087c9898f285c8"
      }
    ],
    "startsAt": "2024-01-02T09:18:18.774Z"
  },
  {
    "id": "675a0274-a5fe-4519-8732-8f9c6b34fe39",
    "status": {
      "state": "expired"
    },
    "updatedAt": "2023-12-29T08:08:55.428Z",
    "comment": "静默测试2",
    "createdBy": "test",
    "endsAt": "2023-12-29T10:07:45.796Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "alertName",
        "value": "test2"
      }
    ],
    "startsAt": "2023-12-29T08:08:55.428Z"
  },
  {
    "id": "bc9a7540-0ad9-45c8-a71c-9df97fe6b2b3",
    "status": {
      "state": "expired"
    },
    "updatedAt": "2023-12-29T08:05:24.539Z",
    "comment": "静默测试",
    "createdBy": "test",
    "endsAt": "2023-12-29T08:05:24.539Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "alertName",
        "value": "test"
      }
    ],
    "startsAt": "2023-12-29T07:46:12.522Z"
  }
]

 

0条评论
0 / 1000
哈哈嗯啦
2文章数
0粉丝数
哈哈嗯啦
2 文章 | 0 粉丝
哈哈嗯啦
2文章数
0粉丝数
哈哈嗯啦
2 文章 | 0 粉丝
原创

AlertManager设置告警静默

2024-11-29 09:12:03
4
0

1 告警静默配置

1.1 AlertManager告警配置页面

1.2 请求url

post /api/v2/silences

1.3 请求参数

{
  "matchers": [                            // 告警匹配规则
    {
      "name": "alertName",
      "value": "告警测试",
      "isRegex": false,
      "isEqual": true
    }
  ],
  "startsAt": "2023-12-28T06:22:00.000Z",  //静默开始时间
  "endsAt": "2023-12-28T08:22:00.000Z",    //静默结束时间
  "createdBy": "test",                      //静默规则由谁创建
  "comment": "告警测试",                    //静默规则说明
  "id": null
}

1.4 返回结果

{"silenceID":"dbc58962-10db-4653-88e3-a1d50eec53c9"}

2 告警静默规则详情

2.1 请求url

GET /api/v2/silence/{silenceID}

2.2 请求参数

silenceId: 创建或者更新静默规则时返回的silenceId

2.2 返回结果

{
    "id": "dbc58962-10db-4653-88e3-a1d50eec53c9",
    "status": {
        "state": "active"
    },
    "updatedAt": "2023-12-28T06:24:32.333Z",
    "comment": "告警测试",
    "createdBy": "test",
    "endsAt": "2023-12-28T08:22:00.000Z",
    "matchers": [
        {
            "isEqual": true,
            "isRegex": false,
            "name": "alertName",
            "value": "告警测试"
        }
    ],
    "startsAt": "2023-12-28T06:24:32.333Z"
}

3 告警静默规则编辑

3.1 请求url

POST /api/v2/silences

3.2 请求参数

{
  "matchers": [
    {
      "name": "alertName",
      "value": "告警测试",
      "isRegex": false,
      "isEqual": true
    },
    {
      "name": "alertId",
      "value": "1",
      "isRegex": false,
      "isEqual": true
    }
  ],
  "startsAt": "2023-12-28T06:24:32.333Z",
  "endsAt": "2023-12-28T08:22:00.000Z",
  "createdBy": "test",
  "comment": "告警测试",
  "id": "dbc58962-10db-4653-88e3-a1d50eec53c9"  //要修改的告警静默规则的silenceId
}

3.3 返回结果

{"silenceID":"122fe701-d953-4d44-8c45-e45a51607e76"}  //新的silenceId

编辑后,原静默规则过期,生成新的静默规则,返回新规则的silenceId.

4 告警静默规则过期

4.1 请求方法

DELETE /api/v2/silence/{silenceId}

4.2 请求参数

silenceId: 创建或者更新静默规则时返回的silenceId

4.3 返回结果

5 查询告警静默规则列表

5.1 请求方法

GET /api/v2/silences?silenced=false&inhibited=false&active=true

5.2 请求参数

silenced:

inhibited:

active:

5.3 返回结果

[
  {
    "id": "4d1bd45b-ff7d-4a4f-ab17-9e552656121b",
    "status": {
      "state": "active"
    },
    "updatedAt": "2024-01-02T09:40:14.955Z",
    "comment": "告警静默测试",
    "createdBy": "test",
    "endsAt": "2024-01-02T11:18:06.560Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "outProdInstId",
        "value": "653eaac1b58b40ab8a087c9898f285c8"
      },
      {
        "isEqual": true,
        "isRegex": false,
        "name": "alertStrategyId",
        "value": "474"
      }
    ],
    "startsAt": "2024-01-02T09:40:14.955Z"
  },
  {
    "id": "a44fb62c-2c9b-404d-81b7-19579e0afe8a",
    "status": {
      "state": "expired"
    },
    "updatedAt": "2024-01-02T09:40:14.955Z",
    "comment": "告警静默测试",
    "createdBy": "test",
    "endsAt": "2024-01-02T09:40:14.955Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "outProdInstId",
        "value": "653eaac1b58b40ab8a087c9898f285c8"
      }
    ],
    "startsAt": "2024-01-02T09:18:18.774Z"
  },
  {
    "id": "675a0274-a5fe-4519-8732-8f9c6b34fe39",
    "status": {
      "state": "expired"
    },
    "updatedAt": "2023-12-29T08:08:55.428Z",
    "comment": "静默测试2",
    "createdBy": "test",
    "endsAt": "2023-12-29T10:07:45.796Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "alertName",
        "value": "test2"
      }
    ],
    "startsAt": "2023-12-29T08:08:55.428Z"
  },
  {
    "id": "bc9a7540-0ad9-45c8-a71c-9df97fe6b2b3",
    "status": {
      "state": "expired"
    },
    "updatedAt": "2023-12-29T08:05:24.539Z",
    "comment": "静默测试",
    "createdBy": "test",
    "endsAt": "2023-12-29T08:05:24.539Z",
    "matchers": [
      {
        "isEqual": true,
        "isRegex": false,
        "name": "alertName",
        "value": "test"
      }
    ],
    "startsAt": "2023-12-29T07:46:12.522Z"
  }
]

 

文章来自个人专栏
狂奔在天翼云
2 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
1
0