Enforce that PromQL expressions (and, optionally, alert definitions) carry a required set of labels — e.g. job, namespace, cluster — to prevent label collisions in multi-tenant Prometheus/Thanos/Cortex/Mimir setups. Use when validating rule YAML for required labels or required alert labels, interactively or as a CI gate. Fully hermetic: no network access or running Prometheus required.
Ships in promql-cody. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Static validator that scans expr:/query: fields (and, in
--check-alerts mode, alert labels: blocks) for a required set of label
names. Hermetic — reads only the files/stdin you give it.
job, sometimes namespace/cluster) to
avoid one team's alert matching another team's series.--alert-labels
actually inspects).go build -o bin/label-check ./cmd/label-check
# or: go install github.com/conallob/o11y-analysis-tools/cmd/label-check@latest
label-check [options] <file|directory>...
Accepts .yml/.yaml files, directories (walked recursively), or
stdin via a literal - argument (e.g. for pre-commit hooks piping a
single expression).
| Flag | Default | Effect |
|---|---|---|
--labels | job | Comma-separated required labels checked against every PromQL expression. |
--check-alerts | false | Also validate each - alert: Name block's labels: section. |
--alert-labels | "" | Comma-separated labels required in each alert's labels: section. Only takes effect with --check-alerts. |
# Default: require 'job' on every expression
label-check --check ./alerts/
# Multiple required labels
label-check --labels=job,namespace,cluster ./alerts/
# Also require alert-level labels
label-check --check-alerts --alert-labels=severity,team ./alerts/
# Single expression via stdin (e.g. pre-commit hook on a diff hunk)
echo 'rate(http_requests_total[5m])' | label-check --labels=job -
--alert-labels checks the alert's labels: block, not
annotations:. The CLI's own -h example (--alert-labels=severity, grafana_url,runbook) is misleading here: runbook and grafana_url
conventionally live under annotations:, not labels:, so checking for
them with this flag will always report them missing even when they're
correctly set as annotations. Only use --alert-labels for names that
are genuinely emitted as alert labels (e.g. severity, team,
tier); it has no way to validate annotations:.{label="..."}/label=~"..."
matcher or in a by (...)/without (...) clause anywhere in the
expression. That means sum(metric) by (job) counts as having the job
label even though job there is a grouping key, not a selector — the
underlying series could still span multiple jobs. Don't treat a pass as
a hard guarantee against label collisions; treat it as a lint, and read
the actual expression when the stakes are high (e.g. an alert routed by
tenant)..label-check.yml) despite it being
mentioned in the repo's top-level README — as of this version, required
labels can only be supplied via --labels/--alert-labels flags on
every invocation. If a user asks for config-file support, tell them it's
aspirational/undocumented-in-code, not implemented../alerts/api-alerts.yml:
Expression: rate(http_requests_total[5m])
Missing required labels: job
Line: 12
Found 1 expressions with missing required labels
Required labels: job
Exit code 1 if any violation is found (expression-level or, with
--check-alerts, alert-level), 0 otherwise.
label-check already, or ask the user) rather than
assuming the job-only default is sufficient for a multi-tenant setup.label-check --labels=<...> <path>. There is no --fix mode — the
agent must manually edit the flagged expression to add the missing
label matcher, using the printed Line: number to locate it, then
re-run to confirm.--check-alerts --alert-labels=... when the required names are
confirmed to be alert labels in this rule set, not annotations —
check an existing alert's labels: block for the convention first.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
7 skills in this plugin
/alert-hysteresisQuery a live Prometheus's historical ALERTS series to statistically recommend better 'for:' hold-down durations, reducing spurious short-lived alerts and alert fatigue. Use interactively when an alert is firing too often/too briefly and needs its hysteresis tuned, or when auditing a rules file's for: values against real firing behavior. Requires a live Prometheus with sufficient ALERTS retention — not hermetic, not a CI check./autogen-promql-testsIdentify Prometheus alert/recording rules that have no promtool unit-test coverage, and scaffold true-positive/false-positive/hysteresis test-case skeletons for them. Use when bootstrapping unit tests for new or existing PromQL rules, or auditing test coverage of a rules file. Fully hermetic: reads only local rule/test YAML, no running Prometheus required.//promql-cody:label-checkfrom promql-cody
npx claudepluginhub conallob/o11y-analysis-tools --plugin promql-cody