SuperAPI AI 工具集

synth-manage-checks

部署与运维

查看项目

更新于 10-15 21:55

技能介绍

用途:使用 gcx 管理 Grafana Synthetic Monitoring(SM)检查,覆盖创建、更新、导出(pull)与推送(push)、删除等操作。核心原则是只调用 gcx 命令,不直接调用 Grafana API(不用 curl 或 HTTP 请求);面向代理处理时用 -o json,面向用户展示时用默认表格格式。gcx 会在调用 API 前做客户端校验(探针名、检查类型、目标格式),checks create/update 的 --dry-run 还会对 SM API 校验但不写入。探针名区分大小写,需从 gcx synthetic-monitoring probes list 原样复制。

主要能力:按目标格式选择检查类型——URL 用 HTTP,主机名或 IP(无端口)用 Ping,域名 DNS 查询用 DNS,host:port 用 TCP,带路由路径分析的 URL 用 Traceroute。可列出并选择探针,建议至少 3 个地理分布探针。用 YAML 定义检查,常见字段包括 apiVersion、kind、metadata.name、spec.job、target、frequency(毫秒)、timeout(须小于 frequency)、enabled、labels、probes、alertSensitivity、basicMetricsOnly、folderUid 及 settings。

使用方式:创建时先写 YAML,再执行 gcx synthetic-monitoring checks create -f <file.yaml> --dry-run 校验,然后去掉 --dry-run 创建;HTTP 检查可用 --validate-targets 做 HEAD 预检。更新时先用 gcx synthetic-monitoring checks get <ID> -o yaml > check-<ID>.yaml 拉取,编辑后执行 gcx synthetic-monitoring checks update <ID> -f check-<ID>.yaml --dry-run 再更新,保持 metadata.name 不变。GitOps 同步用 checks list -o yaml 或 checks get 导出,编辑后逐个 update。删除用 gcx synthetic-monitoring checks delete <ID>,可加 --force 跳过确认,支持多个 ID。创建或更新后可用 checks list、checks status <ID> 验证。

适用场景:需要以声明式 YAML 管理 SM 检查、做版本控制与批量同步、或按地理分布配置探针覆盖时。

限制:探针名区分大小写;timeout 必须严格小于 frequency;frequency 允许范围随检查类型而异;alertSensitivity 默认 none,非 none 在部分栈可能返回 403;folderUid 是 Grafana 文件夹 UID 而非标题,且不会创建文件夹,跨栈推送按字面保留 UID;--dry-run 在 SM API 早于 check/validate(需 synthetic-monitoring-api v0.98.0 或更高)时会失败;MultiHTTP、Browser、Scripted 等复杂类型的 settings 未完整文档化,需拉取同类型现有检查作模板。资料未提供收费、价格与平台信息。