跳转至

获取事件内容



GET /api/v1/events/{doc_id}/get

概述

按事件文档 ID 获取当前工作空间的一条事件原始内容。

调用前和使用步骤

从未恢复事件列表的 content.data[].__docid 取得 doc_id,不能使用 df_event_id 或 df_monitor_checker_event_ref 替代。历史事件建议用 timeRange 指定涵盖事件时间的窗口。成功返回 content 对象;未找到记录时为 {},不会按事件 ID 自动返回 404。省略 timeRange 或传空字符串时使用查询服务的默认窗口;请勿依赖固定历史跨度。本接口使用当前 API Key 所属工作空间,未声明跨空间或跨站点参数。其他空间或站点请使用对应站点 Endpoint 与对应工作空间的 API Key 分别调用。

路由参数

参数名 类型 必选 说明
doc_id string Y 单条事件文档 ID,路径参数。
例子: DOC-EXAMPLE
获取或填写方式: 从未恢复事件列表返回项的 __docid 复制。

请求头

参数名 类型 必选 说明
DF-API-KEY string Y 工作空间的 OpenAPI 鉴权凭据。
例子: <DF-API-KEY>
获取或填写方式: 从目标工作空间的 API Key 管理获取有该操作权限的 OpenAPI Key。

Query 请求参数

参数名 类型 必选 说明
timeRange string 可选时间范围;格式为 [开始毫秒,结束毫秒] 的 JSON 数组字符串。
允许 null: False
例子: [1785427200000, 1785430800000]
获取或填写方式: 根据目标事件的 time 或 date 毫秒值选择覆盖它的开始和结束时刻,将两项数组序列化成字符串并做 URL 编码。

参数补充说明

原始字段含义见事件字段参考。timeRange 声明为字符串,服务端会解析其中的 JSON;必须传两项毫秒数组,非法 JSON 或错误结构可能返回通用内部错误。列表新增的 isRecover、alert_time_ranges、Issue 与故障关联字段不是详情接口的固定输出。

请求例子

curl --get 'https://openapi.guance.com/api/v1/events/DOC-EXAMPLE/get' \
  -H 'DF-API-KEY: <DF-API-KEY>' \
  --data-urlencode 'timeRange=[1785427200000,1785430800000]'

响应

HTTP 200,application/json。下方示例展示可直接读取的主要字段。

字段 类型 说明
content object 查询返回的事件原始字段对象;没有记录为 {}。
content.__docid string 事件文档 ID。将其填入事件详情的路径 doc_id;它与 df_event_id、事件关联标识不同。
content.time integer 事件查询返回的时间,Unix 毫秒。
content.date integer 兼容时间字段;列表中与 time 相同,Unix 毫秒。
content.df_title string 事件标题。
content.df_message string 事件详细描述。
content.df_status string 事件状态。未恢复列表为 fatal、critical、error、warning、nodata;详情还可能为 ok、info 或其他来源定义的恢复状态。
content.df_source string 事件来源,如 monitor 为监控事件、custom 为本模块创建的自定义事件。
content.df_event_id string 事件唯一 ID;不用于详情路径 doc_id。
content.df_monitor_checker_event_ref string 同一触发对象的事件关联标识。用于分组和恢复,不能当作单条事件 ID。
content.df_dimension_tags string 或 null 检测维度标签,常为 JSON 对象序列化的字符串;有值时可解析后读取 service、host 等实际维度。
content.df_check_range_start integer 检测范围开始时间,Unix 秒。列表缺失时补 0。
content.df_check_range_end integer 检测范围结束时间,Unix 秒。列表缺失时补 0。
content.df_fault_start_time integer 或 null 本轮故障开始时间,Unix 秒;仅有来源提供时返回。
content.df_fault_id string 或 null 本轮故障 ID,通常为首次故障事件的 df_event_id。
content.df_monitor_checker string 或 null 检测函数名称,例如 custom_metric。
content.df_monitor_checker_name string 或 null 监控器名称。
content.df_monitor_checker_value number、string 或 null 触发事件时的检测值;单位由监控器的指标配置决定,不能统一当作毫秒。
content.df_monitor_type string 或 null 监控类型,如 custom、slo、bot_obs。集成采集 integration_collection 不参与此未恢复列表。
content.df_workspace_uuid string 或 null 事件记录中的工作空间标识。
content.df_meta string、object 或 null 来源提供的扩展元数据;字符串可为 JSON 序列化值。结构依事件来源而异。
content.df_bot_obs_detail string、object 或 null 智能巡检事件的附加详情,非该来源可缺失。
content.df_event_detail string、object 或 null 事件来源提供的扩展详情,字段按对应监控类型提供。
content.df_is_silent boolean、number 或 null 来源记录的静默标记;列表不将该原始值统一转换为 boolean。
content.df_sent_target_types array、string 或 null 来源记录的通知目标类型,可能随来源及历史记录形式变化。
content.df_alert_info string、object 或 null 来源记录的告警信息,结构随事件类型变化。
content.df_monitor_checker_id string 来源提供的监控器 UUID,可用于查找监控器配置。
content.df_monitor_id string 来源提供的告警策略 UUID。
content.df_monitor_name string 来源提供的告警策略名。
content.自定义字段 string、number、boolean、array、object 或 null 事件存储的其他原始字段,包括自定义字段。字段名称、结构及单位取决于采集来源,不保证所有事件相同。
content.declaration object 或 null 非空结果中附加的工作空间公共声明;空对象结果不附加。
{
  "code": 200,
  "content": {
    "__docid": "DOC-EXAMPLE",
    "time": 1785430800000,
    "date": 1785430800000,
    "df_title": "checkout-api 响应时间超过阈值",
    "df_message": "最近 5 分钟平均响应时间超过 500 ms。",
    "df_status": "critical",
    "df_source": "monitor",
    "df_event_id": "event-example",
    "df_monitor_checker_event_ref": "checkout-prod-latency",
    "df_dimension_tags": "{\"service\":\"checkout-api\",\"env\":\"production\"}",
    "df_check_range_start": 1785430500,
    "df_check_range_end": 1785430800,
    "df_fault_start_time": 1785430500,
    "df_fault_id": "event-fault-example",
    "df_monitor_checker": "custom_metric",
    "df_monitor_checker_name": "checkout-api 平均响应时间",
    "df_monitor_checker_value": 800,
    "df_monitor_type": "custom",
    "df_workspace_uuid": "wksp_example",
    "df_is_silent": false,
    "df_sent_target_types": [
      "dingtalk"
    ],
    "df_meta": "{}",
    "df_bot_obs_detail": null,
    "df_event_detail": null,
    "df_alert_info": null,
    "df_monitor_checker_id": "rul_example",
    "df_monitor_id": "monitor_example",
    "df_monitor_name": "生产服务告警",
    "declaration": {}
  },
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

未找到事件时

{
  "code": 200,
  "content": {},
  "errorCode": "",
  "message": "",
  "success": true,
  "traceId": "TRACE-EXAMPLE"
}

错误响应

鉴权、限流和公共请求错误参见公共错误定义。

未找到事件为成功空对象。请核对工作空间、站点、__docid 和覆盖事件时刻的 timeRange。

HTTP 状态 errorCode 触发条件 消息或响应说明 处理方式
406 ft.ParameterValidationFailed 请求字段缺失,或字段值违反声明的校验条件 参数解析失败 核对参数位置、字段名、类型和取值。
503 ft.QueryServiceUnavailable 查询服务暂时不可用,真实上游返回 503 查询服务暂时不可用,请稍后重试 读取 content.retryable=true 后退避重试;持续失败时提供 traceId。
406 ft.KodoRequestDeadlineExceeded 事件查询超出后端允许的执行时间 数据查询超时,可能是由于以下原因造成的:数据量过大、网络延迟、服务器负载过高。您可以通过以下方式解决此问题:
1. 添加筛选条件或缩小时间范围后再次进行查询。
2. 稍等一段时间后再次尝试查询。
缩小 timeRange 并核对 doc_id;持续失败时提供 traceId。
406 ft.KodoTooManyRows 查询数据量超出后端限制 查询的数据量超过了最大数量限制,请添加筛选条件或减小时间范围后重新进行查询。 缩小 timeRange 并核对 doc_id;持续失败时提供 traceId。
429 ft.KodoServerOverloaded 查询服务繁忙或过载 当前请求过于频繁,请稍后重试。 退避后重试,并减少同时发起的请求。
500 ft.InternalServerError 查询连接失败、上游服务异常或其他内部错误 内部错误 稍后重试;持续失败时提供 traceId 和脱敏请求。

文档评价

文档内容是否对您有帮助?