Monitor Azure Kubernetes Service(AKS) with Prometheus and Grafana

Steps to be followed

  1. Install Prometheus and Grafana using Helm
  2. Setup Port-forwarding for both Prometheus and Grafana
  3. Create a Service Principal and add roles to AKS cluster RG
  4. Create Data Source in Grafana
  5. Import Azure Monitor for Containers in Grafana
  6. View the metrics in Grafana Dashboard

Install Prometheus and Grafana

# Define public Kubernetes chart repository in the Helm configuration
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
# Update local repositories
helm repo update
# Search for newly installed repositories
helm repo list
# Create a namespace for Prometheus and Grafana resources
kubectl create ns prometheus
# Install Prometheus using HELM
helm install prometheus prometheus-community/kube-prometheus-stack -n prometheus
# Check all resources in Prometheus Namespace
kubectl get all -n prometheus

Configure Prometheus and Grafana

# Port forward the Prometheus service
kubectl port-forward -n prometheus prometheus-prometheus-kube-prometheus-prometheus-0 9090
# Port forward the Prometheus service
kubectl port-forward -n prometheus prometheus-prometheus-kube-prometheus-prometheus-0 9090
# Get the Username
kubectl get secret -n prometheus prometheus-grafana -o=jsonpath='{.data.admin-user}' |base64 -d
# Get the Password
kubectl get secret -n prometheus prometheus-grafana -o=jsonpath='{.data.admin-password}' |base64 -d
# Port forward the Grafana service
kubectl port-forward -n prometheus prometheus-grafana-5449b6ccc9-b4dv4 3000

Create a Service Principal and Assign Role

az ad sp create-for-rbac --role="Monitoring Reader" --scopes="/subscriptions/xxxxxx-xxxx-xxxx-xxxxx/resourceGroups/aksdemocluster-rg"

Create Data Source in Grafana

Import Azure Monitor for Containers in Grafana

View the metrics in Grafana Dashboard

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store