How do you secure Prometheus and Alertmanager endpoints?
IntermediateProductionObservability as Code, Security & Vendor Choices
Answer
By default both serve unauthenticated HTTP, and anyone who reaches them can read every metric (which may leak hostnames, versions and business numbers) or create silences. Layers we apply:
- Do not expose them publicly. Access through Grafana, an authenticating reverse proxy (oauth2-proxy) or
kubectl port-forward. - Native TLS and basic auth via
--web.config.file:
tls_server_config:
cert_file: /etc/prometheus/tls/tls.crt
key_file: /etc/prometheus/tls/tls.key
basic_auth_users:
grafana: $2y$10$...bcrypt-hash...
- NetworkPolicies so only Grafana, the rule evaluators and the proxy can reach port 9090/9093.
- Keep
--web.enable-admin-apioff.
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