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.
More on Observability as Code, Security & Vendor Choices
What does "observability as code" cover, and why insist on it?BeginnerHow do you manage Grafana with Terraform?IntermediateHow do you validate Alertmanager configuration in CI?BeginnerWhat does a CI pipeline for Prometheus rules look like?IntermediateRaw dashboard JSON, Jsonnet/Grafonnet or the Grafana Foundation SDK: which do you pick?AdvancedWhat are monitoring mixins and how do you consume them?Advanced