---
title: Kubernetes Kapsule cluster monitoring with Prometheus & Grafana
description: Learn how to monitor your Kubernetes Kapsule cluster using Prometheus and Grafana by following this step-by-step tutorial.
products:
  - kubernetes
tags: kubernetes kapsule Prometheus monitoring Grafana
hero: assets/scaleway_grafana.webp
dates:
  validation: 2025-07-16
  posted: 2020-03-18
  validation_frequency: 12
difficulty: beginner
usecase:
  - monitoring
ecosystem:
  - third-party
---
import image from './assets/scaleway-prom1.webp'
import image2 from './assets/scaleway-prom2.webp'
import image3 from './assets/scaleway-prom3.webp'
import image4 from './assets/scaleway-prom4.webp'
import image5 from './assets/scaleway-grafana_login.webp'
import image6 from './assets/scaleway-grafana_home.webp'
import image7 from './assets/scaleway-grafana_datasource.webp'
import image8 from './assets/scaleway-grafana_import.webp'
import image9 from './assets/scaleway-grafana_dash_datasource.webp'
import image10 from './assets/scaleway-grafana_dashboard.webp'
import image11 from './assets/scaleway-monito3.webp'

import Requirements from '@macros/iam/requirements.mdx'


Kubernetes Kapsule provides a managed Kubernetes environment to create, configure, and run a cluster of preconfigured machines for containerized applications.

This tutorial will explain how to monitor your [Kubernetes Kapsule](https://www.scaleway.com/en/kubernetes-kapsule/) cluster. The stack that we are going to deploy is based on `Prometheus`, `Grafana`, `kube-state-metrics`, and `node-exporter`. We will use `Helm` to deploy the whole stack.  All applications used for this how-to are well-known and widely-used open-source software that fit well in a Kubernetes environment.

- _[Prometheus](https://prometheus.io)_: `Prometheus` is an application used for monitoring and alerting. It records real-time metrics in a time series database. It is based on a pull model and relies on HTTP for scraping the metrics.
- _[Grafana](https://grafana.com)_: `Grafana` is used for visualizing the metrics scraped by Prometheus and stored in the time series database.
- _[kube-state-metrics](https://github.com/kubernetes/kube-state-metrics)_: `kube-state-metrics` listens to the Kubernetes API server and generates metrics about the state of the objects. The list of the exported metrics is available [here](https://github.com/kubernetes/kube-state-metrics/tree/master/docs). For instance, `kube-state-metrics` can report the number of Pods ready (kube_pod_status_ready), or the number of unschedulable Pods (kube_pod_status_unschedulable).
- _[node-exporter](https://github.com/prometheus/node_exporter)_: The `node-exporter` is a Prometheus exporter for hardware and OS metrics exposed by the Linux Kernel. It allows you to get metrics about CPU, memory, file system for each Kubernetes node.

<Message type="tip">
  Instead of setting up everything manually as described in this tutorial, you can use [Scaleway Cockpit](https://www.scaleway.com/en/cockpit/) to monitor your Kubernetes cluster easily and without additional configuration.
</Message>

<Requirements />

- A Scaleway account logged into the [console](https://console.scaleway.com)
- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization
- [Created a Kapsule cluster](/kubernetes/how-to/create-cluster/)
- A working [kubectl](/kubernetes/how-to/connect-cluster-kubectl/) on your machine
- Installed `helm` (version 3.2+), the Kubernetes [package manager](https://helm.sh/), on your local machine

## Preparing the Kubernetes Kapsule cluster

1. Ensure you are connected to your cluster and `kubectl` and `helm` are installed on your local machine.
2. Add the Prometheus Community Helm repo and the stable Kubernetes repo and update them:
    ```
    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    helm repo add stable https://kubernetes-charts.storage.googleapis.com/
    helm repo update
    ```

## Deploying Prometheus

We are first going to deploy the `Prometheus` stack in a dedicated Kubernetes [namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) called "`monitoring`". We will set the retention time for 30 days and create a persistent volume (based on [Scaleway Block Storage](https://www.scaleway.com/en/block-storage/)) to store the `Prometheus` data.

1. Use the `helm` package manager to install the stable release of Prometheus. Set the following parameters to `helm` for both of these:
    - `server.persistentVolume`: 100Gi
    - `server.retention`: 30d

    ```
    helm install prometheus prometheus-community/prometheus --create-namespace --namespace monitoring  --set server.persistentVolume.size=100Gi,server.retention=30d
    NAME:   prometheus
    LAST DEPLOYED: Thu Jan  9 14:30:50 2025
    NAMESPACE: monitoring
    STATUS: DEPLOYED
    [..]
    ```
2. Once the stack is deployed, verify that the created Pods are all running. It is also possible to check if the 100 Gi block volume was created:
    ```
    kubectl get pods,pv,pvc -n monitoring
    NAME                                                READY   STATUS    RESTARTS   AGE
    pod/prometheus-alertmanager-6565668c85-5vdxc        2/2     Running   0          67s
    pod/prometheus-kube-state-metrics-6756bbbb8-6qs9r   1/1     Running   0          67s
    pod/prometheus-node-exporter-fbg6s                  1/1     Running   0          67s
    pod/prometheus-pushgateway-6d75c59b7b-6knfd         1/1     Running   0          67s
    pod/prometheus-server-556dbfdfb5-rx6nl              1/2     Running   0          67s
    ```
3. To access `Prometheus` use the Kubernetes [port forwarding](https://kubernetes.io/docs/tasks/access-application-cluster/port-forward-access-application-cluster/) feature:
    ```
    export POD_NAME=$(kubectl get pods --namespace monitoring -l "app=prometheus,component=server" -o jsonpath="{.items[0].metadata.name}")
    kubectl --namespace monitoring port-forward $POD_NAME 9090
    ```
4. Access the `Prometheus` dashboard using the following URL: http://localhost:9090.
    <Lightbox image={image} alt="" />
5. Verify that both `node-exporter` and `kube-state-metrics` metrics are correctly scrapped by `Prometheus`:
    - The `node-exporter` metrics begin with "node\_"
      <Lightbox image={image2} alt="" />

    - The `kube-state-metrics` begin with "kube\_"
      <Lightbox image={image3} alt="" />
6. Prometheus can generate graphs on its own. You can test the feature by choosing metrics to analyze directly in the application:
    <Lightbox image={image4} alt="" />

## Deploying Grafana

We are going to use and deploy `Grafana` to display the `Prometheus` metrics in some pre-defined dashboards. To do so, we are -as always- using `helm`. Once again we deploy it in the monitoring namespace and enable the persistence:

    - `persistence.enable` : true
    - `persistence.type` : pvc
    - `persistence.size` : 10Gi

  Refer to the [Loki](/tutorials/manage-k8s-logging-loki/) tutorial to have additional information about `Grafana`.

1. Add the Helm repo and install Grafana using `helm` with the following commands:
    ```
    helm repo add grafana https://grafana.github.io/helm-charts
    helm install grafana grafana/grafana \
                                  --set persistence.enabled=true,persistence.type=pvc,persistence.size=10Gi \
                                  --namespace=monitoring
    ```
2. Once `Grafana` is installed retrieve the admin password:
    ```
    kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
    ```
3. Configure the port forwarding to access the Grafana Web interface at this address: http://localhost:3000:
    ```
    kubectl port-forward --namespace monitoring service/grafana 3000:80
    Forwarding from 127.0.0.1:3000 -> 3000
    Forwarding from [::1]:3000 -> 3000
    ```
4. Open the Grafana Web Interface in a web browser at `http://localhost:3000`. The login screen displays. Enter the user `admin` and the password recovered in step 2:
    <Lightbox image={image5} alt="" />
5. The welcome screen displays and invites you to complete the configuration of Grafana. Click **Add data source** to configure a new data source:
    <Lightbox image={image6} alt="" />
6. Choose **Prometheus** as data source from the list of available options.
7. Enter the details of the data source. You can leave the default settings and add the data source: `http://prometheus-server`. Click **Test & Save** to validate the connection to Prometheus and to save the settings:
    <Lightbox image={image7} alt="" />
8. Click the **+** sign and then **Import** to import a ready-to-use dashboard from the Grafana website. To create a dashboard that uses _kube-state-metrics_, import the dashboard number [8588](https://grafana.com/grafana/dashboards/8588) and get information about your Deployment, Statefulset, and Daemonset:
    <Lightbox image={image8} alt="" />
9. Choose `Prometheus` as data source and click **Import**.
    <Lightbox image={image9} alt="" />
10. Access the dashboard with metrics for Deployment, Statefulset, and Daemonset:
    <Lightbox image={image10} alt="" />
11. You can also configure additional dashboards, for example, the node exporter full dashboard ([1860](https://grafana.com/grafana/dashboards/1860)) to display a dashboard with system metrics for each Kubernetes node:
    <Lightbox image={image11} alt="" />

You now have basic monitoring for your Kubernetes Kapsule cluster. For more information on how to configure your cluster, refer to the official [Kubernetes documentation](https://kubernetes.io/docs/home/).

## External links

- [kube-state-metrics](https://github.com/kubernetes/kube-state-metrics)
- [node-exporter](https://github.com/prometheus/node_exporter)
- [Prometheus and Alert Manager](https://prometheus.io)
- [Grafana](https://grafana.com)