query-metrics

작성자: axiomhq

스크립트를 통해 Axiom MetricsDB에 메트릭 쿼리를 실행합니다. 사용 가능한 메트릭, 태그 및 태그 값을 탐색합니다. 메트릭 쿼리, 메트릭 탐색 등을 요청받았을 때 사용하세요.

npx skills add https://github.com/axiomhq/skills --skill query-metrics

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

  1. scripts/datasets <deploy> --kind otel:metrics:v1 — list metrics datasets.
  2. scripts/metrics-spec <deploy> <dataset>required before composing any query. MPL evolves; the spec is the source of truth.
  3. scripts/metrics-info <deploy> <dataset> metrics — list metrics with {type, temporality, unit} metadata. Read this before writing the query (see Choosing a Query Shape).
  4. scripts/metrics-info <deploy> <dataset> tags [<tag> values] — explore filter dimensions.
  5. 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.

FieldValuesDrives
typeGauge, CounterMonotonic, CounterNonMonotonic, HistogramRequired pre-aggregation operators.
temporalityCumulative, Delta, nullWhether counter values are running totals or per-interval deltas. null is normal for Gauges.
unitUCUM string (Cel, kW.h, s, %, [ppm], …) or nullDisplay 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 avg produces nonsense. Use the bucket/quantile operators from metrics-spec.
  • 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 <deploy> '<MPL>' <start> <end>
ParameterNotes
deployName from ~/.axiom.toml (e.g. prod).
MPLPipeline string. Dataset is parsed from the MPL itself.
start / endRFC3339 (2025-01-01T00:00:00Z) or relative (now-1h, now).

Examples:

scripts/metrics-query prod \
  '`my-dataset`:`http.server.duration` | align to 5m using avg' \
  now-1h now

scripts/metrics-query prod \
  '`my-dataset`:`http.server.duration`
   | where `service.name` == "frontend" and method == "GET"
   | align to 5m using avg
   | group by status_code using sum' \
  now-1d now

Parameters

MPL can declare parameters (param $svc: string;). Pass values with repeated -p name=value. The script applies the API's param__ prefix; values are forwarded verbatim as MPL literals (string literals include their quotes).

scripts/metrics-query \
  -p svc='"frontend"' \
  -p window='5m' \
  prod \
  'param $svc: string; param $window: Duration;
   `otel-metrics`:`http.server.duration` | where `service.name` == $svc | align to $window using avg' \
  now-1h now

Required parameters must be supplied; optional ones may be omitted. Resulting request body shape:

{
  "apl": "param $svc: string; …",
  "startTime": "now-1h",
  "endTime": "now",
  "params": { "param__svc": "\"frontend\"", "param__window": "5m" }
}

Literal syntax per type lives in metrics-spec.

Discovery (metrics-info)

Time range defaults to the last 24h; override with --start / --end.

CommandReturns
metrics-info <d> <ds> metricsAll metrics, keyed by name, with {type, temporality, unit}.
metrics-info <d> <ds> metrics --by-typeSame listing grouped by type (client-side reshape).
metrics-info <d> <ds> metrics --type Gauge --type HistogramFiltered listing (repeatable, OR semantics; composes with --by-type).
metrics-info <d> <ds> metrics <metric> infoSingle metric's {type, temporality, unit}. Non-zero exit if absent.
metrics-info <d> <ds> metrics <metric> describeBundle: metadata + all tags + tag values in one call (replaces 1+1+N round trips). Flags: --no-values (tag names only), --values-limit N (cap per-tag values; default 50, 0 = unlimited).
metrics-info <d> <ds> metrics <metric> tagsTags carried by a specific metric.
metrics-info <d> <ds> metrics <metric> tags <tag> valuesTag values for that metric.
metrics-info <d> <ds> metrics <metric> tags <tag> typeProbe whether the tag is int/float/string/bool. Returns {type, present_types}; mixed if multiple types coexist, absent if not present.
metrics-info <d> <ds> tagsAll tags in the dataset.
metrics-info <d> <ds> tags <tag> valuesAll values for a tag (across metrics).
metrics-info <d> <ds> find-metrics "<value>"Metrics that carry the given tag value (not metric name).

Error Handling

HTTP errors return JSON with message, code, and optional detail:

{"message": "...", "code": 400, "detail": {"errorType": 1, "message": "raw error"}}
CodeCause
400Invalid query syntax or bad dataset name
401Missing/invalid auth
403No permission
404Dataset not found
429Rate limited
500Internal error

On 500, re-run with curl -v to capture the traceparent / x-axiom-trace-id header and report it — the trace ID is what the backend team needs to debug.

Scripts

ScriptUsage
scripts/setupCheck requirements and config.
scripts/datasets <deploy> [--kind <kind>]List datasets with edge deployment.
scripts/metrics-spec <deploy> <dataset>Fetch the MPL query spec.
scripts/metrics-query <deploy> <mpl> <start> <end>Execute a query.
scripts/metrics-info <deploy> <dataset> ...Discover metrics, tags, values.
scripts/axiom-api <deploy> <method> <path> [body]Low-level API calls.
scripts/resolve-url <deploy> <dataset>Resolve to the edge deployment URL.

Run any script without arguments for full usage.

axiomhq의 다른 스킬

axiom-apl
axiomhq
APL 쿼리 언어 레퍼런스 for Axiom. 연산자, 함수, 패턴 및 CLI 사용법을 제공합니다. 전문화된 Axiom 스킬에 의해 작성 시 자동 호출됩니다…
official
detect-anomalies
axiomhq
Axiom 데이터셋에서 통계적 분석을 사용하여 이상 징후를 탐지합니다. 비정상적인 패턴, 볼륨 급증, 이상치 또는 새로운 오류 유형을 찾을 때 사용하세요.
official
explore-dataset
axiomhq
Axiom 데이터셋을 탐색하여 스키마, 필드, 볼륨 및 패턴을 이해합니다. 새 데이터셋을 발견하거나 데이터 구조를 조사할 때 사용합니다.
official
find-traces
axiomhq
Axiom에서 OpenTelemetry 분산 트레이스를 분석합니다. 트레이스 ID를 조사하거나, 기준(오류, 지연 시간, 서비스)별로 트레이스를 찾거나, 디버깅할 때 사용하세요…
official
gilfoyle
axiomhq
당신이 할 수 없는 일을 해내는 SRE 에이전트. 관측 가능성 스택을 조회합니다. 근본 원인을 찾아냅니다. 당황하지 않습니다. 추측하지 않습니다. 당신의 감정에 신경 쓰지 않습니다. 사용…
official
axiom-sre
axiomhq
전문 SRE 조사관으로서 인시던트 및 디버깅을 수행합니다. 가설 기반 방법론과 체계적 트라이지를 사용합니다. 사용 가능 시 Axiom 관찰 가능성을 쿼리할 수 있습니다.…
official
building-dashboards
axiomhq
API를 통해 Axiom 대시보드를 설계하고 구축합니다. 차트 유형, APL 및 메트릭/MPL 쿼리 패턴, SmartFilters, 레이아웃, 구성 옵션을 다룹니다. 다음 경우에 사용하세요…
official
controlling-costs
axiomhq
Axiom 쿼리 패턴을 분석하여 사용되지 않는 데이터를 찾고, 비용 최적화를 위한 대시보드와 모니터를 구축합니다. Axiom 비용 절감, 미사용 데이터 찾기 요청 시 사용하세요.
official