К основному содержанию
скилл CX Codex

promql-cli — скилл для Claude Code: запросы к Prometheus

Скилл учит агента гонять PromQL через CLI promql-cli: instant- и range-запросы, поиск метрик, вывод таблицей, CSV, JSON или графиком.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add samber/cc-skills --skill promql-cli -a claude-code
Открыть на GitHub

Что делает promql-cli

Скилл описывает работу с promql-cli — Go-утилитой для запросов к Prometheus и совместимым движкам вроде Thanos, Cortex, VictoriaMetrics, Grafana Mimir и Grafana Tempo. Агент получает набор правил: как проверять конфиг перед запросом, как читать ошибки подключения и авторизации, какие форматы вывода выбирать. Внутри — справочные файлы по установке, использованию, графикам, отладке и самому PromQL, которые агент читает перед задачей.

Для работы нужны два бинарника: promql и jq. Хост и учётные данные скилл советует держать в ~/.promql-cli.yaml и ~/.promql_token с правами 600, потому что токен в аргументах командной строки попадает в историю шелла и список процессов. Конфиг с секретами агент создавать не будет — он попросит вас сделать это вручную и дождаться подтверждения.

Отдельный блок правил про стоимость запросов: сначала посчитать кардинальность метрики, согласовать временное окно, агрегировать на стороне Prometheus, а не в Python. Если запрос идёт дольше 15 секунд, скилл велит сузить область — добавить фильтры по лейблам или укоротить --start. Для range-запросов он предпочитает --output graph, чтобы не тащить тысячи строк JSON в контекст модели.

Какие задачи решает

  • выполнить instant- или range-запрос к Prometheus из терминала
  • найти имя метрики, её лейблы и тип через metrics, labels и meta
  • разобраться, почему метрика пропала: проверить up по job и instance
  • посмотреть тренд латентности или ошибок ASCII-графиком
  • сократить объём данных, который уходит в контекст модели

Примеры запросов агенту

  • покажи rate(http_requests_total[5m]) за последний час графиком
  • какие лейблы есть у метрики node_cpu_seconds_total?
  • проверь up{job="api"} — данные пропали с одного инстанса

Как установить promql-cli

1Через Skills CLI (Vercel)

npx skills add samber/cc-skills --skill promql-cli -a claude-code

2Вручную: положить файлы

~/.claude/skills/promql-cli/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/promql-cli/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Из того же набора19

chrome-extension Помогает создавать и дорабатывать Chrome-расширения на Manifest V3. Пригодится для manifest.json, content scripts, фоновой логики и API браузера. CX Codex +1 4 500установок influence-and-negotiation Скилл-переговорщик: готовит к сделке, зарплатному разговору или сложному 1:1 и подсказывает, что ответить прямо в диалоге. CX Codex +1 4 500установок site-launch-checklist Пошагово готовит веб-сайт к релизу через серию проверок: от DNS, TLS и CSP-заголовков до SEO, аналитики и соответствия GDPR. Пригодится перед выкаткой проекта в прод. CX Codex +1 4 400установок copywriting-prose-creator Создаёт PROSE.md с правилами лексики, синтаксиса и ритма бренда. Нужен для единого стиля текстов у авторов и ИИ. CX Codex +1 4 500установок substack-ghostwriting Пишет и адаптирует выпуски рассылок и статьи для Substack с подбором авторского тона. Помогает тестировать идеи через Notes и оформлять посты под конверсию в подписчиков. CX Codex +1 4 400установок press-release-writer Пишет пресс-релизы для запусков, раундов инвестиций, партнёрств и кризисных коммуникаций. Подстраивает формат под тип медиа и регион. CX Codex +1 4 400установок training-report Собирает структурированный отчёт о тренинге или воркшопе через интервью и экспортирует черновик Markdown в итоговый документ .docx. CX Codex +1 4 200установок skill-progressive-disclosure-design Помогает решить, что оставить в SKILL.md, а что вынести в references/, чтобы скилл не съедал контекст зря. CX Codex +1 4 300установок

Похожие

promql grafana Пишет и проверяет запросы PromQL к Prometheus, Mimir и Grafana Cloud Metrics. Помогает, когда p95 считается неверно или запрос тормозит. CX Codex +1 8 000установок promql-generator akin-ozer Скилл ведёт агента по шагам планирования и собирает PromQL-запросы, правила алертов и recording rules для Prometheus. CX Codex +1 615установок promql-validator akin-ozer Проверяет синтаксис PromQL, находит антипаттерны вроде rate() на gauge-метриках и помогает оптимизировать запросы Prometheus через пошаговый диалог. CX Codex +1 604установок prometheus grafana Справочник по PromQL, правилам алертов Prometheus и маршрутизации Alertmanager. Помогает генерировать метрики, алерты и правила записи. CX Codex +1 5 200установок prometheus-grafana devops-skills Скилл помогает агенту поднять сбор метрик в Prometheus, писать запросы PromQL и собирать панели Grafana. Пригодится, когда в проект нужно добавить мониторинг. CX Codex +1 449установок grafana-dashboards Seth Hobson Скилл помогает создавать Grafana-дашборды для метрик систем и приложений. Подойдёт для мониторинга, SLO и операционных интерфейсов наблюдаемости. CX Codex 13 097установок

Рядом в теме «DevOps и инфраструктура»

Всё по теме «DevOps и инфраструктура» →

Вопросы о promql-cli

Как установить promql-cli в Claude?

Выполните npx skills add samber/cc-skills --skill promql-cli -a claude-code — скилл встанет в ~/.claude/skills/promql-cli/SKILL.md. Отдельно поставьте бинарники promql и jq.

Что делает promql-cli?

Даёт агенту готовые правила для запросов к Prometheus и PromQL-совместимым движкам: instant- и range-запросы, поиск метрик и лейблов, вывод таблицей, CSV, JSON или ASCII-графиком.

Что нужно настроить до первого запроса?

Хост и учётные данные в ~/.promql-cli.yaml и ~/.promql_token с правами 600. Скилл намеренно не создаёт конфиг за вас, потому что в нём лежат токены и пароли.

Исходный текст

SKILL.md · MIT
---
name: promql-cli
description: CLI for querying Prometheus and PromQL-compatible engines (Thanos, Cortex, VictoriaMetrics, Grafana Mimir, Grafana Tempo...) — instant queries, range queries, metric discovery (metrics/labels/meta subcommands), output formats (table/csv/json/graph). Apply when executing PromQL queries, troubleshooting performance issues on a software having observability, investigating latency/error rates/saturation, or analyzing time series data.
license: MIT
compatibility: Requires promql-cli and jq
user-invocable: true
metadata:
  author: samber
  version: "1.2.0"
  openclaw:
    emoji: "📊"
    homepage: https://github.com/samber/cc-skills
    install:
      - kind: go
        package: github.com/nalbury/promql-cli
        bins: [promql]
      - kind: brew
        formula: jq
        bins: [jq]
    requires:
      bins:
        - promql
        - jq
    skill-library-version: "0.3.0"
allowed-tools: Read Edit Write Glob Grep Agent Bash(promql:*) mcp__context7__resolve-library-id mcp__context7__query-docs AskUserQuestion
---

# promql-cli — Prometheus Query CLI Skill

`promql-cli` (github.com/nalbury/promql-cli) is a Go CLI for querying, analyzing, and visualizing Prometheus metrics, plus PromQL fundamentals.

## Reference Files

Read the relevant reference file(s) before executing tasks:

| File | When to read |
| --- | --- |
| `references/installation.md` | User needs to install promql-cli or set up configuration (hosts, auth, token, password, multi-host) |
| `references/usage.md` | User wants to discover metrics/exporters/labels, run queries, or choose output formats |
| `references/graphing.md` | User wants to visualize Prometheus data as an ASCII chart in the terminal |
| `references/debugging.md` | User is investigating a performance issue, latency, errors, saturation, data gaps, or query cost issues |
| `references/promql-reference.md` | User needs help writing PromQL, understanding metric types, functions, or aggregations |

For most tasks, read `references/usage.md`. For PromQL help, read `references/promql-reference.md`. When debugging, read both `references/debugging.md` and `references/promql-reference.md`.

## Setup Check

Before running any query, verify that a host is configured:

```bash
promql 'up'   # succeeds if host is reachable; fails with connection error if not configured
# or
promql --host xxx 'up'
```

Recognize these errors as a configuration/auth problem and refer to `references/installation.md`:

| Error | Cause |
| --- | --- |
| `dial tcp ... connection refused` | No host running at the configured address |
| `dial tcp ... no such host` | Hostname not resolved — wrong host in config |
| `error querying prometheus: ...401...` | Bearer token missing or invalid |
| `error querying prometheus: ...403...` | Token valid but insufficient permissions |
| `please specify an authentication type` | Auth flags partially set — use config file instead |

If any of these appear, **do not create config files on behalf of the user** — config files may contain credentials (tokens, passwords) that must never pass through an LLM. Instead, guide the user to set it up themselves:

> "Please create `~/.promql-cli.yaml` manually with your Prometheus host (and credentials if needed). See `references/installation.md` for the exact format. Let me know once it's ready."

Only after the user confirms the config is in place should you proceed with queries.

## Quick Command Reference

```bash
promql 'up'                                          # instant query
promql 'rate(http_requests_total[5m])' --start 1h    # range query (ASCII graph)
promql 'up' --output csv                             # CSV output
promql 'up' --output json                            # JSON output
promql metrics                                       # list all metric names
promql labels <metric>                               # list labels for a metric
promql meta <metric>                                 # show metric type and help
promql --config ~/.promql-cli-prod.yaml 'up'         # target a specific host
```

## Key Principles

1. **Use `rate()` on counters, never raw values** — raw counters only ever increase; the absolute value is meaningless. `rate()` gives the per-second change rate, which is what you actually care about.
2. **When debugging, isolate a single instance** — aggregating across replicas masks per-instance anomalies. A single overloaded pod hidden behind healthy peers won't show up in averages.
3. **Filter early with label matchers in the innermost selector** — Prometheus evaluates selectors before functions, so filtering late means scanning all time series. Early filters reduce data scanned and query latency.
4. **For histograms, keep `le` in the `by` clause** before `histogram_quantile()` — the function needs all `le` buckets to interpolate percentiles; dropping `le` early produces `NaN` or wrong results.
5. **Prefer `--output graph` for range queries** — ASCII sparklines convey trend direction (rising, falling, spiking) in a compact format that LLMs parse well; raw timestamp tables require mental modeling. Never send thousands of raw JSON/CSV rows into the LLM context — use `--output graph` instead, or run `--output graph` first and `--output table` only to inspect a narrow window.
6. **Store credentials in `~/.promql-cli.yaml` and `~/.promql_token`, chmod 600** — passing tokens as CLI args exposes them in shell history and process listings.

## Query Cost Rules

Always apply these before and during any query session:

0. **Always use the promql CLI** — never call the Prometheus HTTP API from Python scripts or shell `curl`. The CLI handles auth, formatting, and output consistently; Python API calls bypass all of that and produce raw JSON that must be parsed, inflating context and masking the graph output that models interpret best.
1. **Check cardinality first** — before querying an unfamiliar metric, count its time series (`count(metric_name)`). High-cardinality metrics without label filters time out or flood the output. See `references/debugging.md` for patterns.
2. **Confirm the time window upfront** — always ask before running range queries. Large intervals are expensive; prefer multiple short-interval queries over one long one.
3. **Clarify past vs. recent** — for new investigations, ask whether the user wants a past event (specific timestamp) or a recent trend. If recent, offer concrete choices: last hour, last day, last week, last month.
4. **Aggregate in Prometheus** — never pull raw series to aggregate in Python or shell. Push `sum by(...)`, `avg by(...)`, or `topk()` into the PromQL expression — Prometheus collapses series server-side.
5. **Timeout = query too broad** — if a query takes >15s, reduce scope: add label filters, shorten `--start`, or add an aggregation wrapper. Apply the same narrowed scope to all subsequent queries in the session.
6. **Data gaps → check `up`** — when a metric shows missing data, run `up{job="...", instance="..."}` before diagnosing the application. A `0` value confirms the exporter was down. See `references/debugging.md`.

This skill is not exhaustive. Please refer to the [official promql-cli documentation](https://github.com/nalbury/promql-cli) and examples for up-to-date information. Context7 can help as a discoverability platform.

If you encounter a bug or unexpected behavior in promql-cli itself, open an issue at [https://github.com/nalbury/promql-cli/issues](https://github.com/nalbury/promql-cli/issues).

© samber · MIT · samber/cc-skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой