query-metrics
它能做什么
这项技能对存储在 Axiom 中的指标进行搜索。适合跟踪系统或应用度量、又不想手动编写每条查询的人。
适用场景
- ✓当你想查找 Axiom 数据集中有哪些可用指标时。
- ✓当你需要某个指标在一段时间范围内的数值时。
- ✓当你想找出哪些指标带有某个特定服务或主机名时。
技能链接
https://github.com/openclaw/clawhub/blob/main/.agents/skills/query-metrics/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请显示我 API 服务过去一天的请求次数指标。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会列出指标及其标签,读取查询规则,然后在你选择的时间范围内对数据集运行查询。它会不断优化查询,直到结果能回答你的问题。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Querying Axiom Metrics
All script paths are relative to this skill's folder; invoke as scripts/<name>. The target dataset must be of kind otel:metrics:v1.
Setup, prerequisites, and ~/.axiom.toml configuration: see README.md. Edge-deployment routing is automatic — the scripts read each dataset's edgeDeployment and route to the right regional endpoint without configuration.
Workflow
scripts/datasets <deploy> --kind otel:metrics:v1— list metrics datasets.scripts/metrics-spec— required before composing any query. MPL evolves; the spec is the source of truth. Also use it to answer general MPL/metrics questions.scripts/metrics-info <deploy> <dataset> metrics— list metrics with{type, temporality, unit}metadata. Read this before writing the query (see Choosing a Query Shape).scripts/metrics-info <deploy> <dataset> tags [<tag> values]— explore filter dimensions.scripts/metrics-query <deploy> '<MPL>' <start> <end>— execute. Iterate.
If the user names a specific entity (service, host, …), scripts/metrics-info <deploy> <dataset> find-metrics "<value>" finds the metrics carrying it. find-metrics searches tag values, not metric names — don't use it for general discovery.
Choosing a Query Shape
The metrics-info listing returns each metric's {type, temporality, unit}. Read these before composing — never assume a metric is a simple scalar.
| Field | Values | Drives |
|---|---|---|
type |
Gauge, CounterMonotonic, CounterNonMonotonic, Histogram |
Required pre-aggregation operators. |
temporality |
Cumulative, Delta, null |
Whether counter values are running totals or per-interval deltas. null is normal for Gauges. |
unit |
UCUM string (Cel, kW.h, s, %, [ppm], …) or null |
Display unit; preserve when reporting results. |
Rules per type (consult metrics-spec for exact operator names — they evolve):
- Gauge — instantaneous value. Align directly with
avg/min/max/sum. Don't apply a rate; you'd be averaging meaningless deltas of an instantaneous value. - CounterMonotonic + Cumulative — running total (resets aside). The raw values are rarely what you want. Convert to a per-second rate first, then align/aggregate.
- CounterMonotonic + Delta — already per-interval. Sum/align without a rate step.
- CounterNonMonotonic — can go up or down (queue depth, balance). Intent is ambiguous: rate, delta, or current value all make sense for different questions. Ask the user before picking one.
- Histogram — not a scalar.
align using avgproduces nonsense. Usebucket … usingwith the histogram functions frommetrics-spec; quantiles are float specs to those functions, andtemporalityselects the variant (CumulativevsDeltainterpolation). Consultmetrics-specfor the exact signatures. temporality: null— "not applicable for this instrument type" (the norm for Gauges), not "missing data".
When surfacing numbers, attach the unit (treat null as unitless). If you combine metrics with mismatched units in arithmetic, warn rather than silently producing a meaningless number.
Query Metrics
scripts/metrics-query [-w pixels] [--pixel-per-point n] <deploy> '<MPL>' <start> <end>
| Parameter | Notes |
|---|---|
deploy |
Name from ~/.axiom.toml (e.g. prod). |
MPL |
Pipeline string. Dataset is parsed from the MPL itself. |
start / end |
RFC3339 (2025-01-01T00:00:00Z) or relative (now-1h, now). |
-w / --chart-width <px> |
Optional. Target chart width in pixels; lets the server resolve $__interval. |
--pixel-per-point <n> |
Optional. Pixels per point (server default 10); with -w sets the bucket count. |
Always single-quote the MPL string in the shell. MPL is full of backticks; inside double quotes the shell executes them as command substitution, silently mangling the query (or running whatever the identifier names).
Bound the output before grouping. group by <tag> returns one series per tag value with no cap — on a high-cardinality tag this floods the output. Check cardinality first (describe, or tags <tag> values) and prefer plain group using <agg> while exploring.
Examples:
scripts/metrics-query prod -w 1200 \
'`my-dataset`:`http.server.duration` | align to $__interval using avg' \
now-1h now
scripts/metrics-query prod -w 1200 \
'`my-dataset`:`http.server.duration`
| wh
常见问题
我需要了解查询语言吗?
不需要深入了解。智能体会先读取查询规则,再为你编写查询。
它需要什么设置?
必须先按照该技能的 readme 说明配置好你的 Axiom 访问设置。
它可以按名称查找指标吗?
它搜索的是标签值,因此最适合查找带有已知服务名或主机名的指标。
详情
作者的原始描述
Runs metrics queries against Axiom MetricsDB via scripts. Discovers available metrics, tags, and tag values. Use when asked to query metrics, explore metric datasets, check metric values, or investigate OTel metrics data.
repo: openclaw/clawhub
热度
- GitHub 星标
- 9.5k
- 排名
- #12263
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
axiom-alerting
9.5k帮你的智能体通过 Axiom API 创建和管理监控器与通知路由,并检查告警是否按预期运行。
axiom-sre
9.5k帮你的智能体逐步调查生产事故和缺陷,在得出结论之前,用 Axiom 日志验证每一个猜测。
building-dashboards
9.5k帮你的智能体从仪表盘必须支持的决策出发,设计配有合适图表、查询和筛选器的 Axiom 仪表盘。
controlling-costs
9.5k帮你的智能体在 Axiom 中找出未被使用的数据,并构建用于追踪和削减日志成本的仪表盘与监控器。