Interview Prep/Monitoring & Observability/Observability as Code, Security & Vendor Choices

Should application `/metrics` endpoints be protected, and how?

IntermediateProductionObservability as Code, Security & Vendor Choices
Answer

Yes, when the port is reachable from outside the cluster or across tenants. Metrics expose internal routes, versions, queue names and traffic volumes, and a scrape can be expensive enough to be a DoS vector.

Practical options: serve metrics on a separate internal port (:9090 for metrics, :8080 for traffic) that the Ingress never routes; restrict that port with a NetworkPolicy allowing only the Prometheus namespace; or use kube-rbac-proxy in front so Prometheus authenticates with its service account token (bearerTokenFile / authorization in the ServiceMonitor). Never put secrets, emails or tokens in label values.

All Monitoring & Observability questions

More on Observability as Code, Security & Vendor Choices