Command Palette

Search for a command to run...

Grafana Installation Guide

A comprehensive guide for installing and configuring Grafana visualization platform

Grafana is an open-source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources.

Prerequisites

  • A system running Linux, macOS, or Windows
  • Administrative/sudo privileges
  • Terminal/Command Prompt access
  • Minimum 2GB RAM
  • 1GB free disk space
  • Internet connection for downloading packages

Installation Instructions

Ubuntu/Debian Installation

# Install required dependencies
sudo apt-get install -y apt-transport-https software-properties-common
 
# Add Grafana GPG key
wget -q -O - https://apt.grafana.com/gpg.key | sudo apt-key add -
 
# Add Grafana repository
echo "deb https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
 
# Update package list
sudo apt-get update
 
# Install Grafana
sudo apt-get install grafana -y
 
# Start Grafana service
sudo systemctl start grafana-server
sudo systemctl enable grafana-server

Post-Installation Configuration

Initial Setup

  1. Access Grafana web interface:
http://localhost:3000
  1. Default login credentials:
  • Username: admin
  • Password: admin
  1. You'll be prompted to change the password on first login.

Basic Configuration File (grafana.ini)

[server]
http_port = 3000
domain = localhost
 
[security]
admin_user = admin
# Disable user signup
allow_sign_up = false
 
[auth.anonymous]
enabled = false
 
[smtp]
enabled = false
# Configure for email alerts
# host = smtp.gmail.com:587
# user = your-email@gmail.com
# password = your-app-specific-password

Adding Data Sources

  1. Click on Configuration (gear icon) > Data Sources
  2. Click "Add data source"
  3. Select your data source type (e.g., Prometheus)
  4. Configure the connection details:
URL: http://localhost:9090  # For local Prometheus
Access: Server (default)
Scrape interval: 15s

Verification

  1. Check service status:
sudo systemctl status grafana-server
  1. Verify logs:
sudo journalctl -u grafana-server
  1. Test API endpoint:
curl http://localhost:3000/api/health

Common Configuration Options

Enable HTTPS

  1. Generate SSL certificate:
sudo mkdir -p /etc/grafana/ssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
  -keyout /etc/grafana/ssl/grafana.key \
  -out /etc/grafana/ssl/grafana.crt
  1. Update configuration:
[server]
protocol = https
cert_file = /etc/grafana/ssl/grafana.crt
cert_key = /etc/grafana/ssl/grafana.key

Configure SMTP for Alerts

[smtp]
enabled = true
host = smtp.gmail.com:587
user = your-email@gmail.com
password = your-app-specific-password
from_address = grafana@your-domain.com
from_name = Grafana Alert

Troubleshooting

Common Issues

  1. Cannot Access Web Interface

    • Verify service is running
    • Check firewall settings
    • Confirm port 3000 is not in use
    • Check logs for errors
  2. Database Connection Issues

    • Verify database permissions
    • Check connection string
    • Ensure database service is running
  3. Plugin Installation Failures

    • Check internet connectivity
    • Verify plugin compatibility
    • Check disk space
    • Review plugin installation logs

Security Considerations

  1. Change default admin password immediately
  2. Use HTTPS in production
  3. Implement authentication (LDAP, OAuth, etc.)
  4. Regular backups of configuration and data
  5. Keep Grafana updated
  6. Use secure passwords for data source connections
  7. Implement rate limiting
  8. Enable audit logging

Additional Resources