promql-cli
samber/cc-skills
CLI for querying Prometheus and PromQL-compatible engines with instant/range queries, metric discovery, and multiple output formats.
What is promql-cli?
promql-cli is a Go-based command-line tool for querying Prometheus, Thanos, Cortex, VictoriaMetrics, Grafana Mimir, and Grafana Tempo. Use it to execute PromQL queries, discover metrics and labels, troubleshoot performance issues, and analyze time series data in your observability stack.
- Execute instant and range PromQL queries against Prometheus-compatible backends
- Discover available metrics, labels, and metric metadata
- Output results in multiple formats: table, CSV, JSON, and ASCII graphs
- Isolate and debug per-instance performance anomalies
- Query multiple Prometheus hosts via configuration files
- Visualize time series trends with terminal-based ASCII sparklines
How to install promql-cli
npx skills add https://github.com/samber/cc-skills --skill promql-cli- promql-cli binary installed (via Go or Homebrew)
- jq installed for JSON processing
- Prometheus or PromQL-compatible server (Thanos, Cortex, VictoriaMetrics, Grafana Mimir, Grafana Tempo) accessible and running
- Configuration file (~/.promql-cli.yaml) with host and authentication details if not using CLI flags
How to use promql-cli
- 1.Verify connectivity by running `promql 'up'` to confirm your configured host is reachable
- 2.Use `promql metrics` to list all available metric names in your Prometheus instance
- 3.Use `promql labels <metric>` to discover label dimensions for a specific metric
- 4.Execute instant queries with `promql '<PromQL expression>'` for point-in-time values
- 5.Execute range queries with `promql '<PromQL expression>' --start 1h` to see trends over time
- 6.Use `--output csv`, `--output json`, or `--output graph` to change result format
- 7.Reference `promql-reference.md` for PromQL syntax help (rate(), histogram_quantile(), aggregations, etc.)
Use cases
- Investigating latency spikes or error rate increases in production systems
- Discovering which metrics are available in your Prometheus instance
- Analyzing saturation metrics (CPU, memory, disk) across instances
- Comparing performance between different service replicas or environments
- Generating CSV/JSON exports of metrics for external analysis or reporting
- SREs and DevOps engineers troubleshooting observability data
- Backend engineers investigating performance issues in their services
- Platform teams managing multi-tenant or multi-region Prometheus deployments
- Anyone writing or debugging PromQL queries
promql-cli FAQ
Create ~/.promql-cli.yaml with your host URL and authentication details (bearer token or basic auth). Never pass credentials as CLI arguments; store them in the config file with chmod 600 permissions. See references/installation.md for exact format.
'connection refused' means the host is not running or unreachable at the configured address. '401' means your bearer token is missing or invalid. Check your ~/.promql-cli.yaml configuration and verify the host is running and credentials are correct.
Always use rate() on counters. Raw counter values only increase and are meaningless in isolation. rate(counter[5m]) gives you the per-second change rate, which is what you actually want to monitor.
Use label matchers to isolate a single instance in your query (e.g., `rate(http_requests_total{instance='pod-1'}[5m])`). Aggregating across replicas masks per-instance anomalies; a single overloaded pod hidden behind healthy peers won't show up in averages.
Use `--output graph` for range queries. ASCII sparklines show trend direction (rising, falling, spiking) in a compact format. Raw timestamp tables require manual analysis.
Full instructions (SKILL.md)
Source of truth, from samber/cc-skills.
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.1.3" 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, or saturation |
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:
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.yamlmanually with your Prometheus host (and credentials if needed). Seereferences/installation.mdfor 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
- 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. - 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.
- 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.
- For histograms, keep
lein thebyclause beforehistogram_quantile()— the function needs alllebuckets to interpolate percentiles; droppingleearly producesNaNor wrong results. - Prefer
--output graphfor range queries — ASCII sparklines convey trend direction (rising, falling, spiking) in a compact format that LLMs parse well; raw timestamp tables require mental modeling. - Store credentials in
~/.promql-cli.yamland~/.promql_token, chmod 600 — passing tokens as CLI args exposes them in shell history and process listings.
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.
Related skills
More from samber/cc-skills and the wider catalog.

site-launch-checklist
Pre-launch checklist orchestrating analytics, SEO, security, legal compliance, and quality gates for shipping websites.

skill-progressive-disclosure-design
Design how to split skill content between SKILL.md and reference files for context efficiency.

snyk-agent-scan-compliance
Fix snyk-agent-scan alerts in skill files through content restructuring, not suppression.

substack-ghostwriting
Write, optimize, and grow Substack newsletters and web posts with voice matching, algorithm optimization, and monetization strategy.

technical-article-writer
Write compelling technical articles and blog posts for developer audiences with structured workflows.

training-report
Generate professional training and workshop reports as .docx files with structured feedback and recommendations.