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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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

Related routes

Configure HorizontalPodAutoscaler v2 with custom and external metrics
kubernetes.io · 6 steps · unrated
Configure VPA (Vertical Pod Autoscaler) in recommendation mode alongside HPA to gather right-sizing data without automatic eviction, and understand the conflict constraints
kubernetes.io · 5 steps · unrated
Configure Prometheus federation to aggregate metrics from multiple Prometheus servers into a global view
prometheus.io · 6 steps · unrated

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?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans