Run PromQL queries, inspect alert state, and troubleshoot OAuth2 or OIDC client-credentials access to Prometheus-compatible APIs.
95
Quality
95%
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Use this tile to run instant PromQL queries against a Prometheus-compatible HTTP API using OAuth2 or OIDC client credentials.
Set the required environment variables:
export PROM_QUERY_PROMETHEUS_URL="https://prometheus.example.com"
export PROM_QUERY_TOKEN_URL="https://auth.example.com/oauth/token"
export PROM_QUERY_CLIENT_ID="prometheus-reader"
export PROM_QUERY_CLIENT_SECRET="replace-me"Validate the configuration before querying:
python3 scripts/check_config.py
python3 scripts/prom_query.py configRun an instant query:
python3 scripts/prom_query.py query --expr 'up'Inspect alerts:
python3 scripts/prom_query.py alerts --state firingpython3 scripts/prom_query.py query --expr '<promql>'
PROM_QUERY_PROMETHEUS_URL/api/v1/query.python3 scripts/prom_query.py alerts --state firing|pending|inactive
ALERTS{alertstate="<state>"} through the same endpoint.python3 scripts/prom_query.py config
python3 scripts/prom_query.py token [--refresh]
--refresh to bypass the cache.python3 scripts/check_config.py
Required environment variables:
PROM_QUERY_PROMETHEUS_URL: Base URL for the Prometheus-compatible HTTP API.PROM_QUERY_TOKEN_URL: Token endpoint that accepts OAuth2 client credentials.PROM_QUERY_CLIENT_ID: OAuth2 client ID.PROM_QUERY_CLIENT_SECRET: OAuth2 client secret.Optional environment variables:
PROM_QUERY_SCOPE: Space-delimited scope passed to the token endpoint.PROM_QUERY_CA_BUNDLE: Path to a custom CA bundle for TLS validation.PROM_QUERY_TIMEOUT: Request timeout in seconds. Defaults to 30.XDG_CACHE_HOME: Overrides the cache base directory used for token metadata.The token cache lives at $XDG_CACHE_HOME/prometheus-oidc-query/token-cache.json or ~/.cache/prometheus-oidc-query/token-cache.json when XDG_CACHE_HOME is unset.
query and alerts return JSON objects with:
query: The submitted PromQL expression.response: The decoded Prometheus API response body.alerts also includes state.
config and check_config.py return JSON with:
valid: Boolean validation result.errors: List of validation problems.resolved_config: Redacted effective settings, including URLs, client ID, timeout, and whether a client secret is set.required_env: Presence map for required variables.optional_env: Redacted optional settings.cache: Cache path metadata.token returns JSON with:
source: cache or token_endpointexpires_atexpires_in_secondstoken_typescopecache_path401 or 403 during token acquisition:
PROM_QUERY_TOKEN_URL, client ID, client secret, and optional scope.401 or 403 from Prometheus:
TLS failures:
PROM_QUERY_CA_BUNDLE to the correct CA bundle.Timeouts:
PROM_QUERY_TIMEOUT and verify network reachability to both the token endpoint and Prometheus.Empty Prometheus results:
up before assuming auth is broken.This tile replaces the old internal prom-fetcher package. It intentionally removes:
PROM_FETCHER_* environment namingInstall with Tessl CLI
npx tessl i jobe-skills/prometheus-oidc-query@1.0.0