promql-cli

द्वारा samber

Prometheus और PromQL-संगत इंजनों (Thanos, Cortex, VictoriaMetrics, Grafana Mimir, Grafana Tempo...) पर क्वेरी करने के लिए CLI — इंस्टेंट क्वेरी, रेंज क्वेरी, मीट्रिक खोज (मीट्रिक्स/लेबल/मेटा उप-कमांड), आउटपुट प्रारूप (टेबल/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, or saturation
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.
  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.

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 की और Skills

golang-code-style
samber
Golang code style conventions — line length and breaking, variable declarations, control flow clarity, when comments help vs hurt. Use when writing or reviewing Go code, asking about style or clarity, or establishing project coding standards. Not for naming conventions (→ See `samber/cc-skills-golang@golang-naming` skill), linter configuration (→ See `samber/cc-skills-golang@golang-lint` skill), or doc comments (→ See `samber/cc-skills-golang@golang-documentation` skill).
developmentcode-review
golang-testing
samber
प्रोडक्शन-रेडी गोलैंग टेस्ट — टेबल-ड्रिवन टेस्ट, टेस्टिफाई सूट और मॉक, पैरेलल टेस्ट, फज़िंग, फिक्स्चर, गोलिक के साथ गोरूटीन लीक डिटेक्शन, स्नैपशॉट टेस्टिंग, कोड कवरेज, इंटीग्रेशन टेस्ट, इडियोमैटिक टेस्ट नेमिंग। गो टेस्ट लिखते या रिव्यू करते समय, टेस्टिंग दृष्टिकोण चुनते समय, गो टेस्ट सीआई सेट अप करते समय, या फ्लैकी/स्लो टेस
developmenttestingcode-review
golang-design-patterns
samber
इडियोमैटिक गोलैंग डिज़ाइन पैटर्न — फंक्शनल ऑप्शंस, कंस्ट्रक्टर, एरर फ्लो और कैस्केडिंग, रिसोर्स मैनेजमेंट और लाइफसाइकिल, ग्रेसफुल शटडाउन, रेज़िलिएंस, आर्किटेक्चर, डिपेंडेंसी इंजेक्शन, डेटा हैंडलिंग, स्ट्रीमिंग और अन्य। तब लागू करें जब आर्किटेक्चरल पैटर्न के बीच स्पष्ट रूप से चुनाव करना हो, फंक्शनल ऑप्शंस लागू करना हो, कं
developmentdesigncode-review
golang-error-handling
samber
इडियोमैटिक गोलैंग एरर हैंडलिंग — %w के साथ क्रिएशन और रैपिंग, errors.Is/As, errors.Join, कस्टम एरर टाइप्स, सेंटिनल एरर्स, panic/recover, सिंगल हैंडलिंग रूल, slog के साथ स्ट्रक्चर्ड लॉगिंग, HTTP रिक्वेस्ट लॉगिंग मिडलवेयर, और प्रोडक्शन एरर्स के लिए samber/oops। लॉग एग्रीगेशन थर्ड-पार्टी टूल्स के साथ स्केल पर लॉग्स को उपयोगी बनाने के लिए बनाया गया। Go कोड में एरर्स बनाते, रैप करते, निर
developmentcode-review
golang-performance
samber
गोलांग प्रदर्शन अनुकूलन पैटर्न और पद्धति - यदि X अड़चन है, तो Y लागू करें। इसमें आवंटन कमी, CPU दक्षता, मेमोरी लेआउट, GC ट्यूनिंग, पूलिंग, कैशिंग और हॉट-पाथ अनुकूलन शामिल है। इसका उपयोग तब करें जब प्रोफाइलिंग या बेंचमार्क ने कोई अड़चन पहचान ली हो और आपको उसे ठीक करने के लिए सही अनुकूलन पैटर्न की आवश्यकता हो। इसका उपयोग प्रदर्शन कोड समीक्षा करते समय भी करें ताकि सुधार
developmentcode-review
golang-security
samber
गोलांग के लिए सुरक्षा सर्वोत्तम अभ्यास और भेद्यता रोकथाम। इंजेक्शन (SQL, कमांड, XSS), क्रिप्टोग्राफी, फाइलसिस्टम सुरक्षा, नेटवर्क सुरक्षा, कुकीज़, सीक्रेट्स प्रबंधन, मेमोरी सुरक्षा और लॉगिंग को शामिल करता है। सुरक्षा के लिए Go कोड लिखते, समीक्षा करते या ऑडिट करते समय, या क्रिप्टो, I/O, सीक्रेट्स प्रबंधन, उपयोगकर्ता इनपुट हैंडलिंग या प्रमाणीकरण से जुड़े किसी भी जोख
securitycode-reviewdevelopment
golang-database
samber
Go डेटाबेस एक्सेस के लिए व्यापक मार्गदर्शिका — पैरामीटराइज़्ड क्वेरीज़, स्ट्रक्ट स्कैनिंग, NULL योग्य कॉलम, ट्रांज़ैक्शन, आइसोलेशन लेवल, SELECT FOR UPDATE, कनेक्शन पूल, बैच प्रोसेसिंग, कॉन्टेक्स्ट प्रोपेगेशन और माइग्रेशन टूलिंग। PostgreSQL, MariaDB, MySQL या SQLite के साथ इंटरैक्ट करने वाले Golang कोड को लिखते, समीक्षा करते या डीबग करते समय उपयोग करें; डेटाबेस परीक्षण के लिए; या database/sql, sqlx या pg
developmentdatabase
golang-lint
samber
Golang प्रोजेक्ट्स के लिए लिंटिंग सर्वोत्तम अभ्यास और golangci-lint कॉन्फ़िगरेशन — लिंटर चलाना, .golangci.yml कॉन्फ़िगर करना, nolint निर्देशों के साथ चेतावनियाँ दबाना, लिंट आउटपुट की व्याख्या करना और लिंटर चुनना। इसका उपयोग तब करें जब golangci-lint कॉन्फ़िगर करना हो, लिंट चेतावनियों या nolint सप्रेशन के बारे में पूछना हो, कोड गुणवत्ता टूलिंग सेट अप करनी हो, या लिंटर चुनने हों। इसका उपयोग तब भी करें
developmentcode-reviewtesting