agentleFS
abdullahkhawerabdullahkhawer/devops-skills/skills/prometheus-cli/SKILL.md

prometheus-cli

Skill8 starsChanged 6 months agoApache-2.0View on GitHub

Query Prometheus metrics using the HTTP API via curl. Use for instant queries, range queries, metadata lookups, and alert/rule inspection.

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use the instance and rules below when constructing all Prometheus API commands.

    line 8
  2. Distinctive:

    Update the table below with your Prometheus instance URLs before using this skill:

    line 12
  3. Distinctive:

    If the target instance is unclear, ask the user before running any command.

    line 19
  4. Very specific:

    All API calls use curl with the token read from the instance's token file (see instance table above):

    line 35
  5. Distinctive:

    NEVER target any Prometheus instance not listed in the instance table above.

    line 102
  6. Distinctive:

    Update the instance table with your actual Prometheus URLs before using this skill.

    line 103
  7. Distinctive:

    NEVER print, display, log, or store the contents of any token file or credential value.

    line 104
  8. Very specific:

    Always read the token inline with $(cat <TOKEN_FILE>) — never hardcode a token value in a command.

    line 105
  9. Very specific:

    Always pass -s (silent) to curl to suppress progress output, and pipe through jq for readable output.

    line 106
  10. Very specific:

    NEVER run admin/mutating endpoints (/api/v1/admin/...) without explicit user instruction — these can permanently alter or delete metric …

    line 107
  11. Very specific:

    If a PromQL expression or metric name is unfamiliar, use /api/v1/metadata or /api/v1/labels to explore available metrics before querying.

    line 108
  12. Distinctive:

    If the required token file does not exist, inform the user and stop.

    line 110

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Prometheus CLI Skill

Use the instance and rules below when constructing all Prometheus API commands.

Instances

Update the table below with your Prometheus instance URLs before using this skill:

EnvironmentBase URLToken File
Productionhttps://<your-prometheus-prod-url>~/.prometheus/prod.token
Staginghttps://<your-prometheus-staging-url>~/.prometheus/staging.token

If the target instance is unclear, ask the user before running any command.

Prerequisites (one-time setup by user)

Obtain a Prometheus API token for each instance you intend to use and save it to the corresponding token file (see instance table above). Never print or display token values. Do not perform these steps yourself.

For each instance:

  1. Obtain an API token (via your team or the monitoring platform)
  2. Save it:
mkdir -p ~/.prometheus && echo "<your-api-token>" > <TOKEN_FILE> && chmod 600 <TOKEN_FILE>

Command Format

All API calls use curl with the token read from the instance's token file (see instance table above):

curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \
  "<BASE_URL>/api/v1/<endpoint>" | jq .

Example (production):

curl -s -H "Authorization: Bearer $(cat ~/.prometheus/prod.token)" \
  "https://<your-prometheus-prod-url>/api/v1/query?query=up" | jq .

Available API Endpoints

Read-only (safe, no confirmation needed)

EndpointDescription
/api/v1/query?query=<expr>Instant query — evaluate a PromQL expression at current time
/api/v1/query_range?query=<expr>&start=<ts>&end=<ts>&step=<dur>Range query — evaluate PromQL over a time range
/api/v1/labelsList all label names
/api/v1/label/<name>/valuesList values for a specific label
/api/v1/series?match[]=<selector>Find time series matching a selector
/api/v1/metadataList metric metadata (type, help text)
/api/v1/rulesList all recording and alerting rules
/api/v1/alertsList currently firing alerts
/api/v1/targetsList scrape targets and their health
/api/v1/targets/metadataList metadata for scraped targets
/api/v1/status/configShow current Prometheus configuration
/api/v1/status/flagsShow runtime flags
/api/v1/status/runtimeinfoShow runtime information
/api/v1/status/buildinfoShow build information
/api/v1/status/tsdbShow TSDB stats

Example Queries

Replace <TOKEN_FILE> and <BASE_URL> with the values for your target instance (see instance table above).

# Instant query — CPU usage across all instances
curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \
  "<BASE_URL>/api/v1/query?query=rate(process_cpu_seconds_total[5m])" | jq .

# Range query — memory usage over the last hour (60s step)
curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \
  "<BASE_URL>/api/v1/query_range?query=process_resident_memory_bytes&start=$(date -u -v-1H +%s)&end=$(date -u +%s)&step=60" | jq .

# List all firing alerts
curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \
  "<BASE_URL>/api/v1/alerts" | jq '.data.alerts[]'

# Find series matching a selector
curl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \
  "<BASE_URL>/api/v1/series?match[]=up{job=\"node-exporter\"}" | jq .

Never run — requires explicit human approval

EndpointMethodReason
/api/v1/admin/tsdb/delete_seriesPOSTPermanently deletes time series data
/api/v1/admin/tsdb/clean_tombstonesPOSTPurges deleted data from disk
/api/v1/admin/tsdb/snapshotPOSTTriggers a snapshot (may affect disk/storage)

Rules

  • NEVER target any Prometheus instance not listed in the instance table above. If a URL references a different host, stop and ask the user to confirm.
  • Update the instance table with your actual Prometheus URLs before using this skill.
  • NEVER print, display, log, or store the contents of any token file or credential value.
  • Always read the token inline with $(cat <TOKEN_FILE>) — never hardcode a token value in a command.
  • Always pass -s (silent) to curl to suppress progress output, and pipe through jq for readable output.
  • NEVER run admin/mutating endpoints (/api/v1/admin/...) without explicit user instruction — these can permanently alter or delete metric data.
  • If a PromQL expression or metric name is unfamiliar, use /api/v1/metadata or /api/v1/labels to explore available metrics before querying.
  • For range queries, always verify that the time window (start/end) and step are reasonable — very wide windows with fine steps can produce extremely large responses.
  • If the required token file does not exist, inform the user and stop. Do not attempt to find or guess the token.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.