🎨 Integration with Grafana 🚀
Grafana allows you to visualize logs collected by Loki in a user-friendly interface. Follow the steps below to integrate Loki with Grafana.
📥 Step 1: Install Grafana
🐧 For Debian/Ubuntu:
sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
sudo apt-get update
sudo apt-get install -y grafana
🎩 For RHEL/CentOS:
sudo tee /etc/yum.repos.d/grafana.repo > /dev/null <<EOF
[grafana]
name=Grafana Repo
baseurl=https://packages.grafana.com/oss/rpm
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
EOF
sudo yum install -y grafana
🚀 Step 2: Start and Enable Grafana
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
sudo systemctl status grafana-server
Grafana runs on port 3000 by default. Access it via:
http://localhost:3000
(Default login: admin/admin
)
🔗 Step 3: Add Loki as a Data Source
- Login to Grafana (http://localhost:3000)
- Go to ⚙️ Configuration → Data Sources → Add Data Source
- Select Loki
- In the URL field, enter:
http://<LOKI_SERVER_IP>:3100
- Click Save & Test ✅
📊 Step 4: Create a Dashboard
- Navigate to 📊 Dashboards → New Dashboard
- Click Add a New Panel
- Select Loki as the Data Source
- Enter a Log Query (Example):
{job="nginx-logs"}
- Click Run Query ▶️
- Save the dashboard!
🎯 Next Steps
- ✅ Customize alerts using Grafana Alerting
- ✅ Create dashboards with multiple panels
- ✅ Integrate Loki with Promtail for advanced log collection
🎉 Congratulations! Loki is now integrated with Grafana! 🚀