mcpField
C
cx-incident-management

cx-incident-management

github.com/coralogix云与 DevOps215787 次安装今天更新
代码仓库

关于 cx-incident-management

cx-incident-management 是用于事件分诊、SLO 监控和通知验证的 CLI 技能,面向负责可靠性与事件响应的团队。它串联事件、告警、SLO 和通知检查,并可转向遥测查询进行根因调查。

主要功能

  1. 01筛选、查看和管理事件
  2. 02查看事件时间线与聚合情况
  3. 03检查告警和 SLO 状态
  4. 04核验通知连接器与路由规则
  5. 05测试通知投递
  6. 06通过遥测查询继续排查根因

适用场景

  1. 01按状态或严重程度筛选待处理事件
  2. 02查看事件进展及相关告警
  3. 03识别 SLO 违约或预算消耗情况
  4. 04排查通知未送达或路由错误

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/coralogix/cx-cli --skill cx-incident-management

安装后在 Claude Code 中输入/cx-incident-management确认已加载。

详细介绍

事件管理技能

将此技能用作事件分诊、SLO 监控和通知验证的入口。它负责协调从检测到解决的完整分诊工作流,并关联 cx-alerts 以进行深入告警管理,关联 cx-telemetry-querying 以调查根本原因。


CLI 命令

命令子命令用途
cx incidentslist、get、acknowledge、resolve、close、assign、unassign、events、aggregations管理事件并进行分诊
cx sloslist、get、create、update、delete监控和管理 SLO 定义
cx alertslist、get检查哪些告警正在触发(完整的告警管理请参阅 cx-alerts 技能)
cx notifications connectorslist、get验证通知连接器配置
cx notifications routerslist、get验证通知路由规则
cx notifications presetslist、get检查通知预设模板
cx notifications testconnector、destination、preset、routing-condition、template-render测试通知送达

关键标志:

  • cx incidents list 支持可重复使用的筛选条件:--status(TRIGGERED、ACKNOWLEDGED、RESOLVED)、--severity(INFO、WARNING、ERROR、CRITICAL)、--state(TRIGGERED、RESOLVED)、--assignee、--application-name、--subsystem-name、--contextual-label key=value、--query、--muting muted|unmuted、--start/--end 和 --duration-start/--duration-end
  • cx incidents list 默认每个配置最多返回 100 个事件。使用 --limit <n> 限定每个配置的结果数量,使用 --page-size <n>/--page-token <token> 手动分页;只有在明确需要获取所有页面时才使用 --all。
  • 所有命令均支持通过 -o json 输出结构化结果,并通过 -p <profile> 选择配置
  • cx slos create/update 使用 --from-file <path>(或使用 - 表示从 stdin 读取)

事件分诊工作流

第 1 步:检查活跃事件
cx incidents list -o json
cx incidents list --status TRIGGERED -o json
cx incidents list --severity CRITICAL -o json
cx incidents list --status TRIGGERED --start now-24h --limit 50 -o json

了解当前情况。按严重级别筛选,优先查看紧急事项:

cx incidents list --severity CRITICAL --limit 50 -o json | jq '[.[] | {id, name, state, severity, created_at}]'
第 2 步:获取事件详情
cx incidents get <incident-id> -o json
cx incidents events --incident-id <incident-id> -o json

查看事件时间线和相关事件,了解影响范围及进展。

第 3 步:检查相关告警
cx alerts list -o json

找出当前正在触发的告警。如需深入检查告警,请切换到 cx-alerts 技能。

cx alerts list -o json | jq '[.[] | select(.is_active == true) | {id, name, severity, last_triggered}]'
第 4 步:查看 SLO 状态
cx slos list -o json
cx slos get <slo-id> -o json

检查 SLO 是否正在违约,或错误预算是否已耗尽:

cx slos list -o json | jq '[.[] | {name, status, remaining_budget_percentage}]'
第 5 步:验证通知
cx notifications connectors list -o json
cx notifications routers list -o json
cx notifications presets list -o json

确认通知已通过正确渠道发送给相关人员。

第 6 步:转向根本原因调查

切换到 cx-telemetry-querying 技能,使用日志、追踪和指标调查根本原因。


事件操作

确认
cx incidents acknowledge <incident-id>
cx incidents acknowledge <id1> <id2> <id3>
解决
cx incidents resolve <incident-id>
cx incidents resolve <id1> <id2> <id3>
分配
cx incidents assign <incident-id> --user-id <user-id>
关闭
cx incidents close <incident-id>

SLO 管理

创建 SLO

基于现有 SLO 创建模板:

cx slos get <existing-slo-id> -o json > slo-template.json
# Edit slo-template.json with new service/threshold
cx slos create --from-file slo-template.json
监控 SLO 健康状况
# All SLOs with their status
cx slos list -o json | jq '[.[] | {name, status, target_percentage, remaining_budget}]'

# SLOs that are breaching
cx slos list -o json | jq '[.[] | select(.status != "OK")]'

通知排查

通知未能发送给相关人员时:

1. 检查连接器
cx notifications connectors list -o json | jq '[.[] | {id, name, type}]'

验证所需渠道(Slack、PagerDuty、电子邮件)是否存在且已配置。

2. 检查路由器
cx notifications routers list -o json | jq '[.[] | {id, name, entity_type}]'

验证路由规则是否将正确的告警类型映射到正确的连接器。

3. 测试通知送达
cx notifications test connector --from-file test-connector.json
cx notifications test destination --from-file test-destination.json
cx notifications test preset --from-file test-preset.json
cx notifications test routing-condition --from-file test-condition.json

事件聚合

查看事件模式的概览:

cx incidents aggregations -o json

使用此功能了解事件发生频率、MTTR 趋势和严重级别分布。


核心原则

  • 深入排查前先进行初步研判 - 查询遥测数据前,先检查事件、告警和 SLO
  • 检查 SLO 消耗速率,而不只是状态 - 消耗速率较慢的 SLO 也需要及时关注,以免超出阈值
  • 端到端验证通知链路 - 连接器已创建 → 路由器映射正确 → 测试通知成功送达
  • 结合遥测数据交叉验证 - 初步研判后,使用 cx-telemetry-querying 技能查明根本原因
  • 及时确认 - 确认事件以表明负责人,并停止重复通知
  • 使用事件记录查看时间线 - cx incidents events 会显示事件的完整生命周期

相关技能

  • cx-alerts - 深入管理告警:创建、更新和检查告警定义
  • cx-telemetry-querying - 使用日志、指标、跟踪记录和 RUM 调查根本原因
  • cx-observability-setup - 配置告警的通知渠道和路由

评论

支持 Markdown