关于 ops-monitor
ops-monitor 是用于检查 Datadog、New Relic 和 OpenTelemetry 后端状态的监控技能,面向监控运维人员。它支持配置、告警汇总及定时轮询。
主要功能
- 01配置监控后端凭据
- 02检查健康状态与告警
- 03按后端筛选结果
- 04每 60 秒轮询告警变化
适用场景
- 01查看多个监控后端的状态
- 02追踪新出现或已解决的告警
- 03配置并验证监控连接
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ davepoon/ buildwithclaude --skill ops-monitor安装后在 Claude Code 中输入/ops-monitor确认已加载。
详细介绍
运行时上下文
PREFS="${CLAUDE_PLUGIN_DATA_DIR:-$HOME/.claude/plugins/data/ops-ops-marketplace}/preferences.json"
DD_API_KEY=$(jq -r '.datadog_api_key // empty' "$PREFS" 2>/dev/null)
NR_API_KEY=$(jq -r '.newrelic_api_key // empty' "$PREFS" 2>/dev/null)
OTEL_ENDPOINT=$(jq -r '.otel_endpoint // empty' "$PREFS" 2>/dev/null)
确定 $ARGUMENTS 模式:
- 包含
--setup→ 运行设置流程 - 包含
--watch→ 运行监控模式 - 否则 → 运行默认健康检查
OPS ► MONITOR
设置流程(--setup)
询问要配置哪些后端:
Which monitoring backends would you like to configure?
[Datadog] [New Relic] [OpenTelemetry] [All three]
对于每个选定的后端,通过 AskUserQuestion 的自由文本输入收集凭据(每次询问一个,选项不超过 4 个):
Datadog:
datadog_api_key— API Key,获取地址:app.datadoghq.com/organization-settings/api-keysdatadog_app_key— Application Key,获取地址:app.datadoghq.com/organization-settings/application-keys
New Relic:
newrelic_api_key— User API Key,获取地址:one.newrelic.com/api-keysnewrelic_account_id— New Relic 管理门户中的数字 Account ID
OpenTelemetry:
otel_endpoint— OTEL 兼容后端的基础 URL(例如 https://otlp.grafana.net)
使用原子临时文件交换,将每项凭据写入 preferences.json:
tmp=$(mktemp)
jq --arg k "$KEY" --arg v "$VALUE" '.[$k] = $v' "$PREFS" > "$tmp" && mv "$tmp" "$PREFS"
保存后运行冒烟测试:
- Datadog:
curl -sf -H "DD-API-KEY: $DD_API_KEY" -H "DD-APPLICATION-KEY: $DD_APP_KEY" "https://api.datadoghq.com/api/v1/validate"→ 预期结果:{"valid": true} - New Relic:
curl -sf -H "Api-Key: $NR_API_KEY" "https://api.newrelic.com/graphql" -d '{"query":"{ actor { user { name } } }"}'→ 预期结果:data.actor.user - OTEL:
curl -sf "$OTEL_ENDPOINT/healthz"→ 预期结果:HTTP 200
为每个后端报告 ✅ 或 ❌ 及其状态。
Agent Teams 支持
如果已设置 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1,在同时查询多个后端时使用 Agent Teams。这样可以:
- 并行运行后端探测,并共享上下文(例如:Datadog Agent 检测到延迟激增 → OTEL Agent 可以与追踪数据进行关联)
- 你可以指定关注重点:“先关注 Datadog 警报,然后与 New Relic 交叉核对”
- 实时进度:各 Agent 会在结果到达时报告各自后端的状态
团队设置(仅当启用该标志且配置了多个后端时):
TeamCreate("monitor-probes")
Agent(team_name="monitor-probes", name="datadog-probe", subagent_type="ops:monitor-agent", ...)
Agent(team_name="monitor-probes", name="newrelic-probe", subagent_type="ops:monitor-agent", ...)
Agent(team_name="monitor-probes", name="otel-probe", subagent_type="ops:monitor-agent", ...)
如果未设置该标志,或仅配置了一个后端,则使用单个 monitor-agent 子 Agent。
默认健康检查(无标志)
通过 Agent 工具启动 monitor-agent。将结果显示为格式化仪表板:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
OPS ► MONITOR [<timestamp>]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
DATADOG ✅ healthy (0 alerts)
NEW RELIC 🔴 2 critical entities
OTEL ✅ healthy
──────────────────────────────────────────────────────
Total alerts: 2 Severity: CRITICAL
状态图标:
✅— 健康(0 条警报 / 已配置且可访问)⚠️— 警告(存在警告级别的警报)🔴— 严重(存在严重警报或无法访问)⬜— 未配置
对于每条警报或严重实体,显示:服务名称、警报名称以及相关仪表板链接。
如果未配置任何后端,则显示设置提示:
No monitoring backends configured. Run /ops:monitor --setup to add Datadog, New Relic, or OTEL.
监控模式(--watch)
每 60 秒轮询一次。每次轮询时:
while true; do
RESULT=$(# spawn monitor-agent and capture JSON output)
# Diff against previous tick
# Print: timestamp, changed items only
# 🆕 new alert: <name>
# ✅ resolved: <name>
sleep 60
done
按 Ctrl-C 退出。
--backend 筛选器
如果指定了 --backend datadog|newrelic|otel,则仅查询并显示该后端。
CLI/API 参考
| 后端 | 身份验证标头 | 基础 URL | 健康检查端点 |
|---|---|---|---|
| Datadog | DD-API-KEY: $key + DD-APPLICATION-KEY: $app_key | https://api.datadoghq.com | /api/v1/validate |
| New Relic | Api-Key: $key | https://api.newrelic.com/graphql | POST GraphQL 查询 |
| OTEL | 因后端而异 | $OTEL_ENDPOINT | /healthz |
# Datadog — active alerts
curl -sf \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
"https://api.datadoghq.com/api/v1/monitor?monitor_tags=*&with_downtimes=false" \
| jq '[.[] | select(.overall_state == "Alert" or .overall_state == "Warn")]'
# New Relic — critical entities (GraphQL)
curl -sf \
-H "Api-Key: ${NR_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"query":"{ actor { entitySearch(queryBuilder: {alertSeverity: CRITICAL}) { results { entities { name alertSeverity entityType } } } } }"}' \
"https://api.newrelic.com/graphql"
# OTEL — health check
curl -sf "${OTEL_ENDPOINT}/healthz"
评论
支持 Markdown