Skip to content

Install Grafana

To install Grafana, run 03_grafana.sh script as root user on the monitoring server.

#!/bin/bash

# all packages are installed as root
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root" 1>&2
   exit 1
fi

apt install -y apt-transport-https software-properties-common

# import grafana gpg key
wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key

# add stable grafana repo
echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list

# update the packages info
apt update

# install grafana
apt install -y grafana

# reload the systemd, enable and start grafana
systemctl daemon-reload
systemctl enable grafana-server.service
systemctl start grafana-server

# good then
systemctl status grafana-server

After this script finishes successfully, systemctl status grafana-server command should show running Grafana server with Admin UI available at the IP address of the monitoring server, port 3000.

* grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2024-04-22 12:02:20 UTC; 2min 28s ago
       Docs: http://docs.grafana.org
   Main PID: 3020 (grafana)
      Tasks: 8 (limit: 4558)
     Memory: 47.0M
        CPU: 1.688s
     CGroup: /system.slice/grafana-server.service
             └─3020 /usr/share/grafana/bin/grafana server --config=/etc/grafana/grafana.ini 
               --pidfile=/run/grafana/grafana-server.pid 
                  --packaging=deb 
                     cfg:default.paths.logs=/var/log/grafana cfg:default.paths.da

Grafana Welcome

Default credentials for the Admin UI should be admin for user name and again admin for password. It is wise to change defaults to something more secure at this time.

Danger

Note, if you do a lot of login attempts with incorrect user name or password, that user name might be temporary blocked from logging in; this fact is visible in the /var/log/grafana/grafana.log. To unblock the user, just restart the Grafana server by running systemctl restart grafana-server command.