RousselTMLEARNING

Observability

Prometheus on Kubernetes and the Prometheus web interface

Deploy Prometheus on Kubernetes with kube-prometheus-stack (Prometheus Operator, ServiceMonitor, Alertmanager, Grafana) and use the Prometheus web interface (port 9090): PromQL queries, targets, rules and alerts.

1. Deploying with kube-prometheus-stack #

The reference chart.

Installation #

kube-prometheus-stack components
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts && helm repo update
helm install monitoring prometheus-community/kube-prometheus-stack -n monitoring --create-namespace
kubectl -n monitoring get pods
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata: { name: shop, namespace: shop, labels: { release: monitoring } }
spec:
  selector: { matchLabels: { app: shop } }
  endpoints: [ { port: metrics, interval: 30s } ]
Common mistake: By default, the chart's Prometheus only selects ServiceMonitors carrying the chart's release label: without this label, your targets never appear.

2. The Prometheus web interface #

The first diagnostic tool.

Useful pages #

kubectl -n monitoring port-forward svc/monitoring-kube-prometheus-prometheus 9090
# puis http://localhost:9090
PageUsage
Query (Graph)Test a PromQL query, as a table or a graph
Status > TargetsScraped targets, UP/DOWN state and last error
Status > Service discoveryDiscovered targets before and after relabeling
Alerts, RulesAlerting and recording rules, pending or firing state
Status > TSDBCardinality: the most expensive metrics and labels
Good practice: When a metric is missing in Grafana, first check Status > Targets in the Prometheus interface: the cause is almost always a DOWN or missing target.

Related articles

Time-based vs event-based SLO: understanding, computing and choosing (with the Qonto example)

Differences between time-based SLOs (time slices, uptime) and event-based SLOs (good events over total): defi…

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three trade-offs, …

Prometheus recording rules: speeding up your queries and dashboards

Understand and master Prometheus recording rules: evaluation, naming convention, pitfalls (ratios, empty seri…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!