Monitoring Bliss: Setting Up Prometheus and Grafana for Your Kubernetes Cluster Using Minikube

Tushar Chopra
Google Developer Student Clubs TIET
3 min readAug 9, 2023

Monitoring a Kubernetes cluster is like having a pair of binoculars in the wilderness — it empowers you to navigate through the complexity, foresee challenges, and respond effectively. Prometheus and Grafana, two open-source tools, offer a dynamic duo for monitoring and visualization in Kubernetes environments. In this guide, we’ll explore the architecture, use cases, and step-by-step setup of Prometheus and Grafana, with a focus on using Minikube for a local Kubernetes playground.

Photo by Ibrahim Boran on Unsplash

Understanding Prometheus and Grafana

Prometheus: Architecture and Use Cases

Prometheus is a time-series database and monitoring system designed for reliability and simplicity. It collects metrics from targets (like your Kubernetes pods) via HTTP and stores them in a customizable, highly efficient format. Prometheus’s querying language, PromQL, allows for flexible analysis and alerting. It excels in monitoring dynamic, cloud-native environments, providing insights into resource utilization, application performance, and more.

Photo by Growtika on Unsplash

Grafana: Architecture and Use Cases

Grafana, on the other hand, is a powerful visualization and dashboarding tool that complements Prometheus. It integrates seamlessly to create rich, real-time visualizations of Prometheus data. Grafana supports numerous data sources and offers a wide variety of charting options. It’s not just for monitoring — Grafana dashboards can showcase business metrics, operational performance, and even weather forecasts!

Setting Up Prometheus and Grafana

For our setup, we’ll use Minikube, a lightweight Kubernetes distribution for local development and testing. Let’s get started:

  1. Prometheus Setup

Add the Prometheus Helm repository:

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

Install Prometheus using Helm:

helm install prometheus prometheus-community/prometheus

Expose Prometheus via a NodePort service:

kubectl expose service prometheus-server --type=NodePort --target-port=9090 --name=prometheus-server-ext
minikube service prometheus-server-ext

2. Grafana Setup

  1. Add the Grafana Helm repository:
helm repo add grafana https://grafana.github.io/helm-charts helm repo update

Install Grafana using Helm:

helm install grafana grafana/grafana

Expose Grafana via a NodePort service:

kubectl expose service grafana --type=NodePort --target-port=3000 --name=grafana-ext minikube service grafana-ext

Exploring Your Monitoring Bliss

Now that Prometheus and Grafana are up and running, open your browser and navigate to the URLs provided by Minikube. You can access Prometheus’s web UI for querying and graphing metrics at http://<MINIKUBE_IP>:<PROMETHEUS_PORT>, and Grafana's dashboard interface at http://<MINIKUBE_IP>:<GRAFANA_PORT>.

Use Cases and Beyond

With Prometheus and Grafana in place, you can monitor key Kubernetes metrics like CPU and memory usage, pod health, and network traffic. Create insightful dashboards to visualize trends and patterns. Additionally, set up alerts in Prometheus to receive notifications when thresholds are breached.

While this guide offers a simplified setup, the possibilities with Prometheus and Grafana are vast. You can integrate additional exporters, create custom dashboards, and explore advanced alerting configurations to cater to your unique monitoring needs.

In the world of Kubernetes, Prometheus and Grafana are like trusty companions, guiding you through the intricacies of your cluster and helping you achieve a state of monitoring bliss.

Disclaimer: In production environments, ensure to follow best practices for securing Prometheus, Grafana, and your Kubernetes cluster.

So, there you have it — a comprehensive guide to setting up Prometheus and Grafana for your Kubernetes cluster. Enjoy your newfound monitoring bliss as you explore the depths of your application’s performance and gain insights that empower better decision-making. Happy monitoring!

Published originally at : https://medium.com/@tusharchopra02122002/monitoring-bliss-setting-up-prometheus-and-grafana-for-your-kubernetes-cluster-using-minikube-8913e78fab92

--

--

Tushar Chopra
Google Developer Student Clubs TIET

Web3 Developer @Carmony.io | React Native/ Frontend Developer | DevOps | Cloud Native | UI/UX Designer | Blockchain Developer | Solidity | Penetration Testing