Grafana Installation
4 min readEdit on GitHub
Grafana Installation Guide
Overview
Grafana is an open-source analytics and interactive visualization platform. This guide covers installation across different operating systems and setup configurations.
Linux Installation (Ubuntu/Debian)
Method 1: Using APT Repository (Recommended)
- Install prerequisite packages:
hljs bash
sudo apt-get install -y apt-transport-https software-properties-common wget- Import the GPG key:
hljs bash
sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null- Add repository for stable releases:
hljs bash
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list- Update package list:
hljs bash
sudo apt-get update- Install Grafana OSS:
hljs bash
sudo apt-get install grafanaMethod 2: Using .deb Package
hljs bash
wget https://dl.grafana.com/oss/release/grafana_10.3.0_amd64.deb
sudo dpkg -i grafana_10.3.0_amd64.debmacOS Installation
Method 1: Using Homebrew (Recommended)
hljs bash
# Install Homebrew if not already installed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install Grafana
brew update
brew install grafanaMethod 2: Using Binary
hljs bash
# Download and extract
wget https://dl.grafana.com/oss/release/grafana-10.3.0.darwin-amd64.tar.gz
tar -zxvf grafana-10.3.0.darwin-amd64.tar.gz
cd grafana-10.3.0Windows Installation
Method 1: Using Chocolatey
hljs powershell
# Install Chocolatey if not installed
# Then install Grafana
choco install grafanaMethod 2: Manual Installation
- Download the Windows installer from Grafana Downloads
- Run the installer and follow the setup wizard
- Grafana will be installed as a Windows service
Docker Installation
Quick Start
hljs bash
# Run Grafana in Docker
docker run -d -p 3000:3000 --name=grafana grafana/grafana-oss:latestWith Persistent Storage
hljs bash
# Create volume for data persistence
docker volume create grafana-storage
# Run with persistent volume
docker run -d \
-p 3000:3000 \
--name=grafana \
-v grafana-storage:/var/lib/grafana \
grafana/grafana-oss:latestUsing Docker Compose
hljs yaml
version: '3.8'
services:
grafana:
image: grafana/grafana-oss:latest
container_name: grafana
restart: unless-stopped
ports:
- '3000:3000'
volumes:
- grafana-storage:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin123
volumes:
grafana-storage:Service Management
Linux (systemd)
hljs bash
# Start Grafana service
sudo systemctl start grafana-server
# Enable auto-start on boot
sudo systemctl enable grafana-server
# Check service status
sudo systemctl status grafana-server
# Stop Grafana service
sudo systemctl stop grafana-server
# Restart Grafana service
sudo systemctl restart grafana-server
# View logs
sudo journalctl -u grafana-server -fmacOS (Homebrew)
hljs bash
# Start Grafana
brew services start grafana
# Stop Grafana
brew services stop grafana
# Restart Grafana
brew services restart grafanaManual Start (Binary)
hljs bash
# Navigate to Grafana directory and start
./bin/grafana-serverInitial Setup & Access
Default Access
- URL:
http://localhost:3000 - Default Username:
admin - Default Password:
admin
First Login Steps
- Open browser and navigate to
http://localhost:3000 - Login with default credentials
- Change the default password when prompted
- Complete the initial setup wizard
Configuration
Main Configuration File Locations
- Linux:
/etc/grafana/grafana.ini - macOS (Homebrew):
/usr/local/etc/grafana/grafana.ini - Windows:
<GRAFANA_HOME>\conf\grafana.ini
Common Configuration Changes
hljs ini
# Custom HTTP port
[server]
http_port = 3000
# Custom domain
domain = your-domain.com
# Enable anonymous access
[auth.anonymous]
enabled = true
org_role = Viewer
# SMTP settings for email alerts
[smtp]
enabled = true
host = smtp.gmail.com:587
user = your-email@gmail.com
password = your-app-password
from_address = your-email@gmail.comTroubleshooting
Common Issues
- Port already in use:
hljs bash
# Check what's using port 3000
sudo lsof -i :3000
# Kill process using the port
sudo kill -9 <PID>- Permission issues (Linux):
hljs bash
# Fix permissions
sudo chown -R grafana:grafana /var/lib/grafana
sudo chown -R grafana:grafana /etc/grafana- Service won't start:
hljs bash
# Check logs
sudo journalctl -u grafana-server -n 50
# Check configuration
sudo grafana-server -config /etc/grafana/grafana.ini testLog Locations
- Linux:
/var/log/grafana/grafana.log - macOS:
/usr/local/var/log/grafana/grafana.log - Docker:
docker logs grafana
Next Steps
After installation:
- Add Data Sources (Prometheus, InfluxDB, etc.)
- Import Dashboards from Grafana Community
- Configure Alerts for monitoring
- Set up User Management and organizations
- Configure Plugins for extended functionality
Useful Links
- Grafana Official Documentation
- Grafana Community Dashboards
- Grafana GitHub Repository
- Grafana Cloud (SaaS option)
Quick Commands Reference
hljs bash
# Installation verification
grafana-server -v
# Test configuration
grafana-server test
# Reset admin password
grafana-cli admin reset-admin-password newpassword
# Update Grafana (Linux)
sudo apt-get update && sudo apt-get upgrade grafanaThis guide covers Grafana installation and basic setup. For advanced configurations and integrations, refer to the official Grafana documentation.