Skip to main content

🎨 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

  1. Login to Grafana (http://localhost:3000)
  2. Go to ⚙️ ConfigurationData SourcesAdd Data Source
  3. Select Loki
  4. In the URL field, enter:
    http://<LOKI_SERVER_IP>:3100
  5. Click Save & Test

📊 Step 4: Create a Dashboard

  1. Navigate to 📊 DashboardsNew Dashboard
  2. Click Add a New Panel
  3. Select Loki as the Data Source
  4. Enter a Log Query (Example):
    {job="nginx-logs"}
  5. Click Run Query ▶️
  6. 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! 🚀