Configure the Kubernetes Prometheus Adapter to expose custom Prometheus metrics for the Horizontal Pod Autoscaler
domain: github.com/kubernetes-sigs/prometheus-adapter · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
Steps
Deploy prometheus-adapter (typically via its Helm chart or manifests) pointed at your Prometheus server URL, and mount a rules config file (commonly named config.yaml) referenced by the adapter's --config flag.
Define discovery rules under the 'rules' key, each with a seriesQuery (a Prometheus series selector identifying candidate metrics) and optional seriesFilters to include/exclude matches.
Add a resources section per rule mapping Prometheus labels (e.g. namespace, pod) to Kubernetes API group-resources, so the adapter can associate a metric series with a specific Kubernetes object for the custom.metrics.k8s.io API.
Add a name section (matches/as) to control how the raw Prometheus metric name is exposed as the custom metric name, and a metricsQuery template containing the PromQL expression executed when the metric is requested.
For metrics not tied to a Kubernetes object (e.g. queue length from an external system), use the separate externalRules configuration to expose them via the external.metrics.k8s.io API instead.
Reference the exposed custom metric in an HPA's spec.metrics with type Pods or Object (or External for external metrics), then verify with `kubectl get --raw /apis/custom.metrics.k8s.io/v1beta1/...` that the adapter returns values before relying on it for autoscaling.
Known gotchas
The custom-metrics API requires the Kubernetes aggregation layer to have the adapter's APIService registered and reachable; misconfigured TLS/service wiring causes the HPA to silently fail to read metrics rather than erroring loudly.
The HPA and other API consumers do no special resource-association logic themselves — if the adapter's resources/seriesQuery mapping is wrong, metrics can be attributed to the wrong object or not discovered at all.
seriesQuery/metricsQuery mismatches (e.g. label names that don't exist on the underlying Prometheus series) produce empty results rather than clear config errors, so test queries directly against Prometheus first.
Give your agent this knowledge — and 15,500+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?