BLOG09c: Prometheus Metric Collection Flow

BLOG26: Prometheus Metric collection flow


What type of resource is Prometheus Adapter?

Prometheus Adapter is a Deployment

Installed via Helm → creates:

  • Deployment (pods running the adapter)

  • Service

  • APIService (custom.metrics.k8s.io/v1beta1)

  • ConfigMap (rules)

  • ClusterRole / ClusterRoleBinding

  • ServiceAccount

Important: Prometheus Adapter registers itself as a Kubernetes API extension:

custom.metrics.k8s.io

But the core object running it is a Deployment.


What type of resource is PodMonitor?

PodMonitor is a Custom Resource (CRD)

Created by the Prometheus Operator (kube-prometheus-stack).

CRD:

It tells Prometheus:

“Scrape these pods, at this path, on this port.”

It does NOT run anything — it’s just configuration that the Prometheus Operator converts into Prometheus scrape configs.


Now the Whole Metric Exposure Flow — Brief, Beautiful & Complete

The following sections provide a 10-second summary you can use in your slides or training:


Step 1 — Application exposes metrics

Your dummy app exposes:

in Prometheus format.


Step 2 — PodMonitor tells Prometheus to scrape

PodMonitor selects the pods and creates the scrape config.

Prometheus Operator loads the config → Prometheus begins scraping.


Step 3 — Prometheus stores the metric

Prometheus stores:


Step 4 — Prometheus Adapter translates Prometheus metrics → K8s Custom Metrics API

Adapter rule converts:

Example internal query:

Adapter exposes it at:

Now Kubernetes can “see” the metric.


Step 5 — HPA fetches metric from Custom Metrics API

HPA runs a loop:

Compares:

  • current queue length

  • desired target


Step 6 — HPA scales the Deployment

If queue > target:

If queue < target:


Full Metric Flow Diagram (ASCII)

Copy-paste friendly:


In One Line

Pod → PodMonitor → Prometheus → Prometheus Adapter → Custom Metrics API → HPA → Scaling


Last updated