This guide explains how to set up Loki, Prometheus, and Grafana using Kubernetes to monitor CPU load data from a Python application locally.
🔹 Prometheus - Scrapes metrics from the app
🔹 Loki - Collects & indexes logs
🔹 Grafana - Visualizes the data
Ensure you have the following installed:
- Docker &
Docker Compose
- Colima (for Mac users)
- kind
- kubectl
If Mac user run the following script to install the tools:
brew install colima
colima start
brew install kind
brew install kubectl
Run the following command to build and start the services:
For non-K8 deployment:
docker compose up --build
or
For K8 deployment:
bash kind-setup.sh
-
Open Grafana UI → http://localhost:3000
-
Login with:
- Username:
admin
- Password:
admin
- Username:
-
Navigate to "Configuration" > "Data Sources"
-
Click "Add Data Source" and select Prometheus
-
Set the URL:
http://prometheus:9090
-
Click "Save & Test" 🎯
-
Go to "Create" > "Dashboard"
-
Click "Add a new panel"
-
In the Metrics section, enter:
cpu_load
-
Click "Run query" to visualize CPU load
-
Customize the graph, then click "Save" ✅
-
Navigate to "Logs" in Grafana
-
Select "Loki" as the "Data Source"
-
Set the URL:
http://loki:3100
-
Run a log query to filter logs:
{app="sanitised-data"}
Your sanitised-data service is now fully monitored with Prometheus, Loki & Grafana! 🚀
✅ Metrics → Tracked via Prometheus
✅ Logs → Indexed with Loki
✅ Visualization → Displayed in Grafana