Skip to content

Grafana - Installation and Configuration

Author Date
Emilia 21.02.2025
Updated date Updated by
1.03.2025 Franz

Guide to setup Grafana

sudo apt update
sudo apt-get install -y apt-transport-https software-properties-common wget

# Import the GPG key
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

# To add a repository for stable releases
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

# Run the following command to update the list of available packages:
sudo apt-get update

# Installs the latest OSS release:
sudo apt-get install -y grafana

# start and enable
sudo systemctl daemon-reload
sudo systemctl enable --now grafana-server
systemctl status grafana-server

# Configure Nginx as Reverse Proxy
sudo nano /etc/nginx/conf.d/grafana.conf

server {
    listen 80;
    server_name [server_ip]; # change here

    location / {
        add_header X-Frame-Options DENY;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

# restart nginx 
sudo nginx -t
sudo systemctl restart nginx

Access Grafana Web Interface Now you should be able to access the interface using the username/password admin/admin

http://<server_ip>:3000

Add users

Go in the admin area and create users for you and anyone else, the admin account should never be used.

Add Prometheus as a Data Source

To create a Prometheus data source in Grafana:

  1. Click on the "cogwheel" in the sidebar to open the Configuration menu.
  2. Click on "Data Sources".
  3. Click on "Add data source".
  4. Select "Prometheus" as the type.
  5. Set the appropriate Prometheus server URL (for example, http://127.0.0.1:9090)
  6. Click "Save & Test" to save the new data source.

Get new Dashboard

Go to Grafana Dashboards and search for Node Exporter Full Use Dashboard ID: 1860 (or any other)

Then, import the dashboard:

  1. In Grafana, click + Create → Import
  2. Paste 1860 in the "Import via Grafana.com" field