警告管理告警 API
- Tier: 基础版, 专业版, 旗舰版
- Offering: JihuLab.com, 私有化部署
极狐GitLab Alert Management alerts API 限于度量图片。有关更多 API 端点,请参见 GraphQL API。
上传度量图片
plaintextPOST /projects/:id/alert_management_alerts/:alert_iid/metric_images
| Attribute | Type | Required | Description |
|---|---|---|---|
| id | integer/string | yes | 项目的 ID 或 URL 编码路径。 |
| alert_iid | integer | yes | 项目警报的内部 ID。 |
示例请求:
shellcurl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \ --form 'file=@/path/to/file.png' \ --form 'url=http://example.com' \ --form 'url_text=Example website' \ --url "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images"
示例响应:
json1{ 2 "id":17, 3 "created_at":"2020-11-12T20:07:58.156Z", 4 "filename":"sample_2054", 5 "file_path":"/uploads/-/system/alert_metric_image/file/17/sample_2054.png", 6 "url":"https://example.com/metric", 7 "url_text":"An example metric" 8}
列出度量图片
plaintextGET /projects/:id/alert_management_alerts/:alert_iid/metric_images
| Attribute | Type | Required | Description |
|---|---|---|---|
| id | integer/string | yes | 项目的 ID 或 URL 编码路径。 |
| alert_iid | integer | yes | 项目警报的内部 ID。 |
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images"
示例响应:
json1[ 2 { 3 "id":17, 4 "created_at":"2020-11-12T20:07:58.156Z", 5 "filename":"sample_2054", 6 "file_path":"/uploads/-/system/alert_metric_image/file/17/sample_2054.png", 7 "url":"https://example.com/metric", 8 "url_text":"An example metric" 9 }, 10 { 11 "id":18, 12 "created_at":"2020-11-12T20:14:26.441Z", 13 "filename":"sample_2054", 14 "file_path":"/uploads/-/system/alert_metric_image/file/18/sample_2054.png", 15 "url":"https://example.com/metric", 16 "url_text":"An example metric" 17 } 18]
更新度量图片
plaintextPUT /projects/:id/alert_management_alerts/:alert_iid/metric_images/:image_id
| Attribute | Type | Required | Description |
|---|---|---|---|
| id | integer/string | yes | 项目的 ID 或 URL 编码路径。 |
| alert_iid | integer | yes | 项目警报的内部 ID。 |
| image_id | integer | yes | 图片的 ID。 |
| url | string | no | 查看更多度量信息的 URL。 |
| url_text | string | no | 图片或 URL 的描述。 |
示例请求:
shellcurl --header "PRIVATE-TOKEN: <your_access_token>" \ --request PUT --form 'url=http://example.com' \ --form 'url_text=Example website' \ --url "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images/1"
示例响应:
json1{ 2 "id":23, 3 "created_at":"2020-11-13T00:06:18.084Z", 4 "filename":"file.png", 5 "file_path":"/uploads/-/system/alert_metric_image/file/23/file.png", 6 "url":"https://example.com/metric", 7 "url_text":"An example metric" 8}
删除度量图片
plaintextDELETE /projects/:id/alert_management_alerts/:alert_iid/metric_images/:image_id
| Attribute | Type | Required | Description |
|---|---|---|---|
| id | integer/string | yes | 项目的 ID 或 URL 编码路径。 |
| alert_iid | integer | yes | 项目警报的内部 ID。 |
| image_id | integer | yes | 图片的 ID。 |
示例请求:
shellcurl --request DELETE \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images/1"
可以返回以下状态码:
- 204 No Content: 如果图片删除成功。
- 422 Unprocessable: 如果图片无法删除。