promql-cli

작성자: samber

Prometheus 및 PromQL 호환 엔진(Thanos, Cortex, VictoriaMetrics, Grafana Mimir, Grafana Tempo...)을 쿼리하기 위한 CLI — 즉시 쿼리, 범위 쿼리, 메트릭 검색(metrics/labels/meta 하위 명령어), 출력 형식(table/csv/json/graph). PromQL 쿼리 실행, 관찰 가능성을 갖춘 소프트웨어의 성능 문제 해결, 지연 시간/오류율/포화도 조사, 또는 시계열 데이터 분석 시 적용합니다.

npx skills add https://github.com/samber/cc-skills --skill promql-cli

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:

FileWhen to read
references/installation.mdUser needs to install promql-cli or set up configuration (hosts, auth, token, password, multi-host)
references/usage.mdUser wants to discover metrics/exporters/labels, run queries, or choose output formats
references/graphing.mdUser wants to visualize Prometheus data as an ASCII chart in the terminal
references/debugging.mdUser is investigating a performance issue, latency, errors, saturation, data gaps, or query cost issues
references/promql-reference.mdUser 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:

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:

ErrorCause
dial tcp ... connection refusedNo host running at the configured address
dial tcp ... no such hostHostname 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 typeAuth 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

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:

  1. 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.
  2. 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.
  3. Confirm the time window upfront — always ask before running range queries. Large intervals are expensive; prefer multiple short-interval queries over one long one.
  4. 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.
  5. 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.
  6. 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.
  7. 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 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.

samber의 다른 스킬

chrome-extension
samber
Manifest V3로 Chrome 확장 프로그램을 구축하기 위한 종합 가이드입니다. 사용자가 Chrome 확장 프로그램, 브라우저 확장 프로그램, manifest.json, 콘텐츠 스크립트, 서비스 워커(확장 프로그램 컨텍스트에서), 팝업, 사이드 패널, chrome.runtime, chrome.tabs, chrome.storage, chrome.scripting, 백그라운드 스크립트, MV3, Manifest V3 또는 기타 Chrome 확장 프로그램 API를 언급할 때 이 스킬을 사용하세요. 또한 사용자가 웹 페이지에 스크립트를 삽입하거나, 페이지와 백그라운드 간에 통신하거나, CSP를 우회하려는 경우에도 트리거됩니다.
developmentbrowser-automation
conventional-git
samber
Conventional Commits v1.0.0 브랜치 명명, 워크트리 명명, GitHub 및 GitLab 프로젝트를 위한 커밋 메시지 표준입니다. 브랜치 생성, 워크트리 명명, 커밋 작성, 커밋 메시지 생성, 브랜치 규칙 검토, 체인지로그 자동화 설정 시 사용합니다. 프로젝트에 일관된 Git 히스토리, SemVer 기반 릴리스, 파싱 가능한 체인지로그 생성, 자동 이슈 종료가 필요할 때 적용합니다. 사용자가 워크트리 명명 방법, Git 워크트리 생성 방법 등을 물을 때 트리거됩니다.
developmentcode-reviewdevops
copywriting-cta
samber
기사 하단의 CTA(블로그 포스트, 뉴스레터, 에세이, 기사 또는 모든 장문 콘텐츠의 하단에 배치되는 행동 유도 문구)를 설계합니다. 사용자가 기사, 블로그 포스트 또는 에세이 하단의 CTA를 작성, 설계, 검토 또는 개선해 달라고 요청하거나, "포스트 하단 CTA", "기사 하단", "행동 유도 문구", "가입 박스", "뉴스레터 CTA", "구독 블록", "하단에 무엇을 넣어야 할까요", "독자들이 구독/공유/전화 예약/구매를 하게 하려면 어떻게 해야 하나요" 등을 언급할 때 이 스킬을 사용하세요.
marketingcreativecommunication
copywriting-hooks
samber
긴 형식의 글(블로그 포스트, Substack/Medium/dev.to, LinkedIn 장문, 유료 뉴스레터, 의견 에세이, 보도 특집, 기술 심층 분석)을 위한 오프닝 훅과 포스트 제목을 영어 또는 프랑스어로 생성합니다. 사용자가 훅, 오프닝, 리드, 인트로, 첫 문장/단락, 오프너, accroche, attaque, phrase d'accroche, première phrase를 요청할 때(평범한 인트로를 더 강력하게 만들거나 초안 오프닝을 다시 작성하는 경우 포함) 트리거됩니다. 또한 사용자가 포스트 제목, titre d'article 등을 요청할 때도 트리거됩니다.
marketingcreativecommunication
copywriting-prose-creator
samber
누군가 또는 브랜드의 글쓰기 방식을 체계화합니다 — 감정적 어조와 무관한 산문 메커니즘(어휘, 구문, 리듬, 구조, 시그니처 동작). 출력: PROSE.md. 세 가지 모드: SOUL.md + TONE.md + 발견 인터뷰로 새 가이드 BUILD; 기존 가이드를 새 채널에 ADAPT; 체계화 전 코퍼스의 산문 패턴 AUDIT. 사용 시점: 콘텐츠 팩토리용 글쓰기 규칙 작성, 다중 작성자 일관성을 위한 고스트라이팅 보이스 체계화, 금지어 및 문장 길이 목표 정의 시,...
creativecommunicationdocument
copywriting-tone-of-voice-creator
samber
발견, 음성 정의, 채널 변조를 통해 브랜드 톤 앤 보이스 가이드(TONE.md)를 구축합니다. 다운스트림 콘텐츠 스킬이 브랜드에 맞는 카피를 작성할 때 사용할 음성 속성, 해야 할 일/하지 말아야 할 일, NN/g 포지셔닝, 톤 변조 매트릭스, 어휘, 메커니즘, 채널 규칙을 출력합니다. B2B SaaS, B2C/D2C, NGO, 공공 부문, 컨설팅, 산업, 제품 중심, 개인, 자원봉사 브랜드를 다루며, 정치, 규제 분야, 종교 단체, 게임 등 아직 다루지 않은 맥락을 조사합니다.
marketingcreativecommunication
crxjs
samber
CRXJS Chrome extension development — true HMR for popup, options, content scripts, side panels, manifest-driven builds, dynamic content script imports (`?script`, `?script&module`), and `defineManifest` for type-safe manifests. Uses Vite as its build tool. Use when the user mentions CRXJS, crxjs, @crxjs/vite-plugin, 'extension with hot reload', 'HMR for chrome extension', or wants to set up a CRXJS-based Chrome extension project with any framework (React, Vue, Svelte, Solid, Vanilla). Also...
developmentbrowser-automation
deep-research
samber
심층 연구 스킬 — 광범위한 병렬 웹 검색, 다중 출처 검증, 신뢰도 추적, 인용 포함 마크다운 보고서. 11가지 연구 유형 지원: 시장(TAM/SAM, 세그먼트, 가격, 트렌드), 도메인(산업 구조, 생태계, 규제 환경), 기술(아키텍처, 도구, 벤치마크), 경쟁(경쟁사 분석, 포지셔닝, 승/패), 제품(기능 분석, 리뷰, 로드맵 신호), 학술(문헌 조사, 인용 네트워크, 주요 저자), 인물/조직(실사...
researchweb-scrapingdata-analysis