警告管理告警 API

  1. Tier: 基础版, 专业版, 旗舰版
  2. Offering: JihuLab.com, 私有化部署

极狐GitLab Alert Management alerts API 限于度量图片。有关更多 API 端点,请参见 GraphQL API

上传度量图片#

plaintext
POST /projects/:id/alert_management_alerts/:alert_iid/metric_images
AttributeTypeRequiredDescription
idinteger/stringyes项目的 ID 或 URL 编码路径
alert_iidintegeryes项目警报的内部 ID。

示例请求:

shell
curl --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"

示例响应:

json
1{ 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}

列出度量图片#

plaintext
GET /projects/:id/alert_management_alerts/:alert_iid/metric_images
AttributeTypeRequiredDescription
idinteger/stringyes项目的 ID 或 URL 编码路径
alert_iidintegeryes项目警报的内部 ID。

示例请求:

shell
curl --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images"

示例响应:

json
1[ 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]

更新度量图片#

plaintext
PUT /projects/:id/alert_management_alerts/:alert_iid/metric_images/:image_id
AttributeTypeRequiredDescription
idinteger/stringyes项目的 ID 或 URL 编码路径
alert_iidintegeryes项目警报的内部 ID。
image_idintegeryes图片的 ID。
urlstringno查看更多度量信息的 URL。
url_textstringno图片或 URL 的描述。

示例请求:

shell
curl --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"

示例响应:

json
1{ 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}

删除度量图片#

plaintext
DELETE /projects/:id/alert_management_alerts/:alert_iid/metric_images/:image_id
AttributeTypeRequiredDescription
idinteger/stringyes项目的 ID 或 URL 编码路径
alert_iidintegeryes项目警报的内部 ID。
image_idintegeryes图片的 ID。

示例请求:

shell
curl --request DELETE \ --header "PRIVATE-TOKEN: <your_access_token>" \ --url "https://gitlab.example.com/api/v4/projects/5/alert_management_alerts/93/metric_images/1"

可以返回以下状态码:

  1. 204 No Content: 如果图片删除成功。
  2. 422 Unprocessable: 如果图片无法删除。