DEV Community

Barathiraja
Barathiraja

Posted on

How I Set Up Prometheus and Grafana Monitoring on AKS from Scratch

Setting up a monitoring stack in Kubernetes can be overwhelming if you're doing it for the first time. When I started working with Azure Kubernetes Service (AKS), I realized I needed better visibility into pod and node metrics โ€” thatโ€™s when I turned to Prometheus and Grafana.

In this post, Iโ€™ll walk you through the exact steps I took to get Prometheus and Grafana running on AKS, along with some lessons I learned along the way.

## ๐Ÿ”ง Why Prometheus + Grafana?

  • Prometheus scrapes and stores time-series data from Kubernetes.
  • Grafana gives you beautiful, customizable dashboards.

Together, they provide powerful insights into your clusterโ€™s performance.

## ๐Ÿ› ๏ธ Prerequisites

  • Azure CLI installed and authenticated
  • kubectl configured to your AKS cluster
  • Helm 3 installed
  • A working AKS cluster

๐Ÿš€ Step-by-Step Setup

1. Add the Helm Repos


bash
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update

**Install Prometheus:**

helm install prometheus prometheus-community/prometheus \
  --namespace monitoring --create-namespace
Install Grafana:

helm install grafana grafana/grafana \
  --namespace monitoring
Access the Grafana UI:

You can port-forward and access Grafana at http://localhost:3000:

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

**Login using:**  
    Username: admin
    Password: (from step 4)

**๐Ÿ“Š Importing Dashboards**
Once inside Grafana, go to "Dashboards > Import" and use IDs from Grafana.com like:

Kubernetes Cluster Monitoring: 315

Node Exporter: 1860

**๐Ÿ’ก Lessons Learned**
Always install Prometheus before Grafana if you want dashboards to auto-discover data sources.

Use persistent volumes for Prometheus and Grafana in production.

Set up alerts for critical metrics like pod restarts or high CPU usage.

Iโ€™m planning to extend this by:

Setting up AlertManager

Integrating with Slack for alerts

Enabling SSL and Ingress for Grafana

Stay tuned! ๐Ÿ‘€
Enter fullscreen mode Exit fullscreen mode

Top comments (0)