Interview Prep/Monitoring & Observability/Prometheus and PromQL at Scale

How do you secure Prometheus scraping across namespaces in a cluster?

IntermediateScenarioPrometheus and PromQL at Scale
Answer

Situation read → Metrics endpoints can reveal internals. Scraping must be authenticated and limited by network and RBAC.

What I'd do →

  1. Give Prometheus a ServiceAccount with a ClusterRole limited to get/list/watch on pods, services, endpoints, and nonResourceURLs: ["/metrics"].
  2. Use TLS and bearer tokens for sensitive targets (kubelet, API server, kube-rbac-proxy in front of app metrics).
  3. Use NetworkPolicies: allow ingress to metrics ports only from the monitoring namespace.
  4. Restrict which namespaces the Operator watches (serviceMonitorNamespaceSelector).
  5. Do not expose the Prometheus UI publicly. Put it behind an authenticated proxy (OAuth2 Proxy).

Why → Metrics can leak topology and business numbers, and Prometheus holds powerful discovery credentials.

Interview tip → Mention that Prometheus itself has no built-in user authentication on its UI, so you front it.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus and PromQL at Scale