What you will learn in this TP
- Install kube-prometheus-stack
- Declare collection with a ServiceMonitor
- Create a declarative alert
Prometheus in Kubernetes #
What you will learn in this section
- Install kube-prometheus-stack
- Declare collection with a ServiceMonitor
- Create a declarative alert
Context. In Kubernetes pods come and go: editing prometheus.yml by hand no longer makes sense. The Operator discovers targets from Kubernetes objects (ServiceMonitor, PrometheusRule).
Prerequisites : kind, kubectl, helm · Estimated time : 50 min
Operator, ServiceMonitor, alert rule.1. Install the stack
Why? The chart installs everything at once (Operator, Prometheus, Alertmanager, Grafana); check pods start before going further.
Create a kind cluster then install the chart.2. Deploy an instrumented application
Why? A named port is what the ServiceMonitor references: without a port name the target is never discovered.
An application exposing/metricson a named port.3. Create the ServiceMonitor
Why? The ServiceMonitor replaces configuration editing: monitoring becomes a versioned object like the rest.
Declare collection and check the target in the Prometheus UI.4. Add an alert rule
Why? The PrometheusRule makes the alert declarative; the
Create areleaselabel must match the Operator's selector, otherwise it is ignored.PrometheusRulefiring when the error request rate exceeds 5%.
Difficulty level : ●●●○○ (3/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Recent discussions about this course
- Prometheus consomme 12 Go de RAM : comment trouver les métriques coupables ?✓ solved · 2 reply(ies)
- PromQL : quelle différence entre rate() et irate() ?✓ solved · 1 reply(ies)
Ask a question about this lesson →See all discussions about this course
Course Glossary
Alerting
The process of notifying teams (via email, Slack, Teams) when a specific event, threshold breach, or anomaly is detected.
Architecture
The overall structural design of an IT system, defining its various components, their relationships, and the principles guiding its evolution.
OpenTelemetry
An open source framework providing standards, APIs, and SDKs to collect and export observability data (traces, metrics, logs) in an agnostic way.
Recommended Articles
Prometheus in the Kubernetes world (Operator, ServiceMonitor, kube-prometheus-stack)
Monitor Kubernetes with Prometheus: service discovery, kube-prometheus-stack, Prometheus Operator...
Prometheus on Kubernetes and the Prometheus web interface
Deploy Prometheus on Kubernetes with kube-prometheus-stack (Prometheus Operator, ServiceMonitor, ...
Deploying Thanos on Kubernetes (kube-prometheus-stack, Helm and Operator)
Install Thanos on Kubernetes: sidecar via kube-prometheus-stack, objstore secret, Bitnami/kube-th...
Elastic Agent on Kubernetes
Deploy Elastic Agent on Kubernetes: Fleet-managed DaemonSet, Kubernetes integration, kube-state-m...
Operating VictoriaMetrics: vmalert, backups, Kubernetes and monitoring
Evaluate rules and alerts with vmalert, back up with vmbackup, deploy on Kubernetes with the oper...
Observability on Azure: Azure Monitor, Log Analytics, Application Insights, managed Prometheus and Grafana
A complete overview of observability on Azure: Azure Monitor (metrics, logs and Log Analytics, KQ...
Prometheus recording rules: speeding up your queries and dashboards
Understand and master Prometheus recording rules: evaluation, naming convention, pitfalls (ratios...
Prometheus: visualizing your metrics (UI, Grafana and dashboards)
Visualize Prometheus data: the web interface, PromQL graphs, connecting to Grafana, RED and USE d...
Prometheus best practices: metrics, cardinality, rules and operations
Prometheus best practices: metric naming, labels and cardinality, scrape intervals, recording rul...