Kubernetes native deployment and management of Prometheus and related monitoring components
open sourceApache-2.0self-hostablefree
The Prometheus Operator runs Prometheus, Alertmanager and Thanos Ruler on Kubernetes from custom resources, and keeps them in sync with the cluster by watching the Kubernetes API. ServiceMonitor, PodMonitor, Probe and ScrapeConfig resources describe what to scrape with label selectors, so the operator writes the Prometheus scrape configuration; PrometheusRule holds alerting and recording rules, checked by an admission webhook, and AlertmanagerConfig adds routes and receivers. It installs only the operator: kube-prometheus-stack and the kube-prometheus project build a full cluster monitoring stack on it. It is Apache-2.0, maintained in the prometheus-operator GitHub organization.
Problems it solves
- hand-editing prometheus.yml every time a new service is deployed to the cluster
- let each team declare what to scrape for its own services with a Kubernetes manifest
- run Prometheus on Kubernetes with persistence, retention and replicas set from a YAML resource
- ship alerting rules alongside the app's Helm chart instead of in a central config repo
- a typo in one alert rule broke Prometheus for the whole cluster
- scrape every pod with a given label without writing relabeling rules
- manage Alertmanager routes and receivers per namespace as Kubernetes objects
- monitor ingresses and static URLs from Prometheus with a declarative probe
- run Prometheus in agent mode on Kubernetes to forward metrics with remote write
- GitOps-friendly way to deploy and upgrade Prometheus across many clusters
Features
- Prometheus and PrometheusAgent custom resources for deployments, versions, persistence, retention and replicas
- Alertmanager and ThanosRuler custom resources
- ServiceMonitor and PodMonitor resources that generate scrape configuration from label selectors
- Probe resource for ingresses and static targets
- ScrapeConfig resource for targets outside the cluster
- PrometheusRule resource for alerting and recording rules
- AlertmanagerConfig resource for routes, receivers and inhibit rules
- admission webhook that validates PrometheusRule resources
- watches the Kubernetes API and keeps deployments in sync with the resources
Limitations
- Doesn't install a complete monitoring stack by itself: exporters, dashboards and alert rules come from kube-prometheus or the kube-prometheus-stack Helm chart1
Alternatives
The same job
These do what Prometheus Operator does.
- Amazon Managed Service for Prometheus Serverless, Prometheus-compatible monitoring service for container metrics
- kube-prometheus-stack Helm chart for end-to-end Kubernetes cluster monitoring with Prometheus using the Prometheus Operator
