agents/skills/prometheus/SKILL.md
Query Prometheus/Thanos metrics via the HTTP API. Supports mTLS and PromQL.
npx skillsauth add timofreiberg/dotfiles prometheusInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Query Prometheus and Thanos endpoints using Python (stdlib only). Supports mTLS authentication.
All commands use the helper script in this skill directory.
# Instant query (most common)
python3 query.py -s <source> '<promql>'
# Instant query, flatten labels into columns
python3 query.py -s <source> -f '<promql>'
# Range query (returns time series)
python3 query.py -s <source> -r --start '30m ago' --end 'now' --step 60s '<promql>'
# Label values
python3 query.py -s <source> --label-values <label_name>
# Label values filtered by selector
python3 query.py -s <source> --label-values <label_name> --match '<selector>'
Sources are configured in ~/.config/prometheus/sources.json. List your configured sources there.
count by (label) (metric) to explore what labels existgroup by (label) (metric) to get distinct label combinations without values--flatten / -f makes output much easier to read for the agent — prefer it for instant queriestopk(10, ...) / bottomk(10, ...){instance="host:port"}If your Prometheus/Thanos endpoint requires mTLS, obtain a client certificate, private key, and CA certificate from your infrastructure team.
Place certs wherever you like. A suggested location:
mkdir -p ~/.config/prometheus/certs
# Copy your certs there:
# ~/.config/prometheus/certs/client.crt
# ~/.config/prometheus/certs/client.key
# ~/.config/prometheus/certs/ca.crt
Create ~/.config/prometheus/sources.json:
{
"prod": {
"url": "https://prometheus.example.com/api/v1",
"mtls": {
"cert": "~/.config/prometheus/certs/client.crt",
"key": "~/.config/prometheus/certs/client.key",
"cacert": "~/.config/prometheus/certs/ca.crt"
}
},
"local": {
"url": "http://localhost:9090/api/v1"
}
}
Sources without an mtls block are queried without client certificate auth.
python3 query.py -s prod 'count(up) by (job)' | head -20
Returns JSON array of results. Each element has metric (name + labels) and value (timestamp + value):
[
{"metric": {"__name__": "up", "job": "myservice"}, "value": [1709123456, "1"]}
]
--flattenReturns JSON array with labels promoted to top-level keys alongside __value__ and __timestamp__:
[
{"__name__": "up", "job": "myservice", "__value__": "1", "__timestamp__": 1709123456}
]
Returns JSON array where each element has metric and values (array of [timestamp, value] pairs):
[
{"metric": {"__name__": "up", "job": "myservice"}, "values": [[1709123400, "1"], [1709123460, "1"]]}
]
On error, the script exits non-zero and prints the Prometheus error message to stderr.
development
Quick internet research via a web-search-enabled model. Returns summaries with source URLs.
data-ai
Use when you want to work in an isolated jj working copy — parallel task, experimental scratch, subagent with its own tree. Covers creating a workspace, working inside it from anywhere, and cleaning up without losing history.
tools
Use when working on the pi coding agent harness or writing pi extensions.
testing
Use when creating, editing, or reviewing a skill before it ships. Covers when to write a skill, file layout, the SKILL.md shape, and how to verify it before relying on it.