How to Monitor a Kubernetes Cluster with Prometheus and Grafana

Kubernetes clusters need dedicated monitoring beyond basic kubectl commands — Prometheus and Grafana together provide comprehensive metrics collection and visualization for cluster and application health.

Why Standard VPS Monitoring Isn't Enough

General server monitoring (see How to Set Up Prometheus and Grafana for VPS Monitoring) covers the underlying node, but Kubernetes introduces its own layer of objects (Pods, Deployments, Nodes as cluster resources) that need Kubernetes-aware monitoring to be genuinely useful.

Step 1 — Install Using the kube-prometheus-stack Helm Chart

The community-maintained kube-prometheus-stack bundles Prometheus, Grafana, and pre-built Kubernetes dashboards together (see How to Install and Use Helm: The Kubernetes Package Manager for Helm setup first):

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
helm install monitoring prometheus-community/kube-prometheus-stack

Step 2 — Verify Everything Is Running

kubectl get pods

You should see Pods for Prometheus, Grafana, Alertmanager, and several exporters.

Step 3 — Access the Grafana Dashboard

kubectl port-forward svc/monitoring-grafana 3000:80

Visit http://localhost:3000 — default credentials are typically admin / prom-operator unless customized during installation.

Step 4 — Explore Pre-Built Dashboards

The chart includes ready-made dashboards for cluster overview, node resources, and Pod-level metrics — browse the Dashboards section in Grafana rather than building from scratch.

Step 5 — Expose Grafana Properly (Instead of Port-Forwarding)

For ongoing use, expose Grafana via an Ingress (see How to Expose Applications with a Kubernetes Ingress Controller) rather than relying on temporary port-forwarding:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: grafana-ingress
spec:
  ingressClassName: nginx
  rules:
  - host: grafana.yourdomain.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: monitoring-grafana
            port:
              number: 80

Key Metrics to Watch

  • Node resource usage — CPU/memory pressure across your cluster's underlying VPS instances
  • Pod restart counts — frequent restarts indicate crashing applications
  • Pending Pods — Pods that can't be scheduled, usually indicating insufficient cluster resources
  • Persistent Volume usage — approaching-full storage on stateful workloads

Setting Up Alerts

Alertmanager (included in the stack) can route alerts to email, Slack, or other channels when defined thresholds are breached — configure alert rules for the specific failure conditions most relevant to your applications, following the same principles as How to Set Up Effective Server Alerting (Without Alert Fatigue).

Monitoring Application-Specific Metrics

Beyond cluster/node metrics, instrument your own applications to expose custom metrics (request rates, error rates, business-specific numbers) in Prometheus format, and Prometheus will automatically discover and scrape them if properly annotated.

Common Errors

Grafana shows no data for some dashboards — verify Prometheus is successfully scraping the relevant targets; check under Status → Targets in the Prometheus UI.

Helm install fails with insufficient resources — the full kube-prometheus-stack has meaningful resource requirements; ensure your cluster/node has adequate capacity, especially on a single small VPS.

Continue Reading

Browse more articles in Kubernetes & Container Orchestration.

  • kubernetes monitoring, prometheus kubernetes, grafana kubernetes, kube-prometheus-stack
  • 0 Utenti hanno trovato utile questa risposta
Hai trovato utile questa risposta?

Articoli Correlati

What Is Kubernetes and When Do You Need It on a VPS?

Kubernetes is a container orchestration platform — it automates deploying, scaling, and...

How to Install a Single-Node Kubernetes Cluster with k3s

k3s is a lightweight, certified Kubernetes distribution designed to run efficiently on modest...

How to Install kubeadm and Set Up a Multi-Node Kubernetes Cluster

kubeadm is the official tool for bootstrapping a standard, full-featured Kubernetes cluster. This...

Kubernetes Pods, Deployments & Services Explained

Understanding these three core Kubernetes objects — Pods, Deployments, and Services —...

How to Expose Applications with a Kubernetes Ingress Controller (Nginx Ingress)

An Ingress lets you route external HTTP/HTTPS traffic to multiple services within your cluster...