Here's a step-by-step guide to install Prometheus and Grafana on a Kubernetes
cluster using Helm.
Pre-requisites:
1. Kubernetes Cluster (Ensure kubectl is configured)
2. Helm Installed (v3+)
3. Namespace (optional) for monitoring tools
Step 1: Set Up Helm Repositories
Add the Prometheus Community and Grafana Helm chart repositories:
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
Step 2: Create a Namespace (Optional)
It's good practice to isolate monitoring tools in a dedicated namespace.
kubectl create namespace monitoring
Step 3: Install Prometheus Using Helm
Deploy Prometheus with Helm:
helm install prometheus prometheus-community/prometheus \
--namespace monitoring
Verify Prometheus Deployment:
Confidential
kubectl get pods -n monitoring -l app=prometheus
Step 4: Access Prometheus UI
To access Prometheus UI:
1. Port Forwarding:
kubectl port-forward svc/prometheus-server 9090:80 -n monitoring
Then, access http://localhost:9090.
2. (Optional) Expose via LoadBalancer: Edit the service to type LoadBalancer if
you're on a cloud platform:
kubectl edit svc prometheus-server -n monitoring
# Change type: ClusterIP to type: LoadBalancer
Step 5: Install Grafana Using Helm
Deploy Grafana with Helm:
helm install grafana grafana/grafana \
--namespace monitoring \
--set adminPassword='YourSecurePassword' \
--set service.type=LoadBalancer
Replace 'YourSecurePassword' with a strong password for the Grafana admin user.
Step 6: Access Grafana UI
Confidential
1. Retrieve the Grafana Admin Password: If you didn't set a password manually,
retrieve the auto-generated one:
kubectl get secret --namespace monitoring grafana -o jsonpath="{.data.admin-
password}" | base64 --decode ; echo
2. Get Grafana Service IP:
kubectl get svc -n monitoring grafana
If using LoadBalancer, access Grafana via the provided external IP on port 3000.
Otherwise, use port-forward:
kubectl port-forward svc/grafana 3000:80 -n monitoring
3. Login to Grafana: Open your browser and go to http://localhost:3000.
o Username: admin
o Password: (use the retrieved password)
Step 7: Configure Prometheus as a Data Source in Grafana
1. Login to Grafana.
2. Navigate to Configuration → Data Sources.
3. Click Add data source.
4. Select Prometheus.
5. In the URL field, enter:
pgsql
http://prometheus-server.monitoring.svc.cluster.local
6. Click Save & Test.
Confidential
Step 8: Import Dashboards
1. In Grafana, go to + (Create) → Import.
2. Use Grafana Dashboard IDs from Grafana Dashboards.
3. Import relevant dashboards for Kubernetes, Prometheus, etc.
Step 9: Verify Monitoring
You should now see metrics and dashboards for your Kubernetes cluster.
Optional Configuration: Persistent Volumes
To ensure data persists after pod restarts:
1. Create Persistent Volume Claims (PVCs).
2. Update Helm values during installation:
helm upgrade prometheus prometheus-community/prometheus \
--namespace monitoring \
--set server.persistentVolume.enabled=true \
--set server.persistentVolume.size=8Gi
helm upgrade grafana grafana/grafana \
--namespace monitoring \
--set persistence.enabled=true \
--set persistence.size=8Gi
Uninstall Instructions (if needed)
If you need to uninstall Prometheus and Grafana:
helm uninstall prometheus -n monitoring
Confidential
helm uninstall grafana -n monitoring
kubectl delete namespace monitoring
Confidential