You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过REST API获取GitLab事故类型Issue的时间线事件?

获取GitLab事故类型Issue的时间线事件

你需要使用GitLab专门的Incident Timeline Events API来提取事故的实际时间线事件,这是你之前未尝试的专属接口。

核心接口说明

该API仅适用于GitLab EE版本,端点为:

GET /projects/:id/incidents/:incident_iid/timeline_events

示例请求

curl --location 'https://your-gitlab-instance/api/v4/projects/131/incidents/1/timeline_events' \
--header 'PRIVATE-TOKEN: your-access-token'

示例返回结果

返回的JSON数据会包含你需要的事件类型、描述等关键信息:

[
  {
    "id": 123,
    "incident_id": 94,
    "project_id": 131,
    "action": "added",
    "author": {
      "id": 456,
      "name": "John Doe",
      "username": "johndoe"
    },
    "created_at": "2024-01-25T14:06:00Z",
    "updated_at": "2024-01-25T14:06:00Z",
    "note": null,
    "system": false,
    "timeline_event_type": "impact_detected",
    "description": "Service X became unresponsive for EU users",
    "occurred_at": "2024-01-25T14:00:00Z"
  },
  {
    "id": 124,
    "incident_id": 94,
    "project_id": 131,
    "action": "added",
    "author": {
      "id": 456,
      "name": "John Doe",
      "username": "johndoe"
    },
    "created_at": "2024-01-25T15:30:00Z",
    "updated_at": "2024-01-25T15:30:00Z",
    "note": null,
    "system": false,
    "timeline_event_type": "end_time",
    "description": "Service X fully restored",
    "occurred_at": "2024-01-25T15:25:00Z"
  }
]

关键字段解释

  • timeline_event_type:对应你要找的"Impact detected"/"End time"等事件标签
  • description:事件的详细说明内容
  • occurred_at:事件实际发生的时间(区别于事件被添加到时间线的created_at)
  • author:创建该时间线事件的用户信息

为什么之前的API无法获取?

  • Notes API返回的是系统生成的操作记录(比如"added an incident timeline event"),并非时间线事件本身的结构化数据
  • Events API、resource_*_events接口聚焦于项目级活动或Issue的状态/标签变更,不包含事故专属的时间线事件数据

权限要求

调用该API需要项目的开发者及以上权限,或拥有事故管理相关的权限。

内容的提问来源于stack exchange,提问作者RubenLaguna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 09:53:11