Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Query Prometheus metrics using the HTTP API via curl. Use for instant queries, range queries, metadata lookups, and alert/rule inspection.
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 93% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 70% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 45% | 0% |
| case-06 | ✗→✓ | ▲ Improved | 121% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 98% | 0% |
Use the instance and rules below when constructing all Prometheus API commands.
Update the table below with your Prometheus instance URLs before using this skill:
| Environment | Base URL | Token File | |---|---|---| | Production | https://<your-prometheus-prod-url> | ~/.prometheus/prod.token | | Staging | https://<your-prometheus-staging-url> | ~/.prometheus/staging.token |
If the target instance is unclear, ask the user before running any command.
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:
bashmkdir -p ~/.prometheus && echo "<your-api-token>" > <TOKEN_FILE> && chmod 600 <TOKEN_FILE>
All API calls use curl with the token read from the instance's token file (see instance table above):
bashcurl -s -H "Authorization: Bearer $(cat <TOKEN_FILE>)" \ "<BASE_URL>/api/v1/<endpoint>" | jq .
Example (production):
bashcurl -s -H "Authorization: Bearer $(cat ~/.prometheus/prod.token)" \ "https://<your-prometheus-prod-url>/api/v1/query?query=up" | jq .
| Endpoint | Description | |---|---| | /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/labels | List all label names | | /api/v1/label/<name>/values | List values for a specific label | | /api/v1/series?match[]=<selector> | Find time series matching a selector | | /api/v1/metadata | List metric metadata (type, help text) | | /api/v1/rules | List all recording and alerting rules | | /api/v1/alerts | List currently firing alerts | | /api/v1/targets | List scrape targets and their health | | /api/v1/targets/metadata | List metadata for scraped targets | | /api/v1/status/config | Show current Prometheus configuration | | /api/v1/status/flags | Show runtime flags | | /api/v1/status/runtimeinfo | Show runtime information | | /api/v1/status/buildinfo | Show build information | | /api/v1/status/tsdb | Show TSDB stats |
Replace <TOKEN_FILE> and <BASE_URL> with the values for your target instance (see instance table above).
bash# 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 .
| Endpoint | Method | Reason | |---|---|---| | /api/v1/admin/tsdb/delete_series | POST | Permanently deletes time series data | | /api/v1/admin/tsdb/clean_tombstones | POST | Purges deleted data from disk | | /api/v1/admin/tsdb/snapshot | POST | Triggers a snapshot (may affect disk/storage) |
$(cat <TOKEN_FILE>) — never hardcode a token value in a command.-s (silent) to curl to suppress progress output, and pipe through jq for readable output./api/v1/admin/...) without explicit user instruction — these can permanently alter or delete metric data./api/v1/metadata or /api/v1/labels to explore available metrics before querying.start/end) and step are reasonable — very wide windows with fine steps can produce extremely large responses.Other measured skills in the registry, with their headline benchmark lift.