Prometheus and Grafana setup in Minikube

Prometheus and Grafana setup in Minikube

This article shows how to deploy Prometheus and Grafana into your Minikube cluster using Helm charts. Prometheus is used to monitor Kubernetes Cluster and other resources running on it. Grafana helps to visualize metrics recorded by Prometheus and display them in dashboards.

All installation is done in 'default' namespace.

Start Minikube

minikube start

Install Prometheus

  1. Add prometheus repository
    helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    
  2. Install provided Helm chart for Prometheus
    helm install prometheus prometheus-community/prometheus
    
  3. Expose the prometheus-server service via NodePort
    kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-np
    
  4. Check services:
    kubectl get svc
    

Access Prometheus UI

  1. Expose service URL:
    minikube service prometheus-server-np --url
    
  2. Prometheus UI: ui

Install Grafana

  1. Add Grafana Helm repo:
    helm repo add grafana https://grafana.github.io/helm-charts
    
  2. Install Grafana chart:
    helm install grafana grafana/grafana
    
  3. Expose Grafana service via NodePort in order to access Grafana UI:
    kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-np
    
  4. Check exposed service:
    kubectl get services
    

    Get Grafana admin credentials

    kubectl get secret --namespace default grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
    

Access Grafana Web UI

  1. Expose Grafana service in minikube:
    minikube service grafana-np --url
    
  2. Access UI and enter admin credentials: UI
  3. Add Prometheus data source (use prometheus-server:80 URL): admin
  4. Import default Prometheus dashboards: default
  5. You can also import community based Grafana dashboards. For example you can use dashboard with 6417 id: import

Reference

  1. Prometheus
  2. Grafana