{{< details >}}

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

{{< /details >}}

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

上传度量图片

POST /projects/:id/alert_management_alerts/:alert_iid/metric_images
Attribute Type Required Description
id integer/string yes 项目的 ID 或 URL 编码路径
alert_iid integer yes 项目警报的内部 ID。

示例请求:

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"

示例响应:

{
  "id":17,
  "created_at":"2020-11-12T20:07:58.156Z",
  "filename":"sample_2054",
  "file_path":"/uploads/-/system/alert_metric_image/file/17/sample_2054.png",
  "url":"https://example.com/metric",
  "url_text":"An example metric"
}

列出度量图片

GET /projects/:id/alert_management_alerts/:alert_iid/metric_images
Attribute Type Required Description
id integer/string yes 项目的 ID 或 URL 编码路径
alert_iid integer yes 项目警报的内部 ID。

示例请求:

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

示例响应:

[
  {
    "id":17,
    "created_at":"2020-11-12T20:07:58.156Z",
    "filename":"sample_2054",
    "file_path":"/uploads/-/system/alert_metric_image/file/17/sample_2054.png",
    "url":"https://example.com/metric",
    "url_text":"An example metric"
  },
  {
    "id":18,
    "created_at":"2020-11-12T20:14:26.441Z",
    "filename":"sample_2054",
    "file_path":"/uploads/-/system/alert_metric_image/file/18/sample_2054.png",
    "url":"https://example.com/metric",
    "url_text":"An example metric"
  }
]

更新度量图片

PUT /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 的描述。

示例请求:

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"

示例响应:

{
  "id":23,
  "created_at":"2020-11-13T00:06:18.084Z",
  "filename":"file.png",
  "file_path":"/uploads/-/system/alert_metric_image/file/23/file.png",
  "url":"https://example.com/metric",
  "url_text":"An example metric"
}

删除度量图片

DELETE /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。

示例请求:

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: 如果图片无法删除。