blog-image

May 23, 2024

9 min read

How To Install and Configure Grafana on Debian 11

Written by

Abdelhadi Dyouri

Grafana is an open-source monitoring and data visualization software. It provides analytics and interactive visualization on the web for your servers, with features offering charts, graphs, and alerts. It supports integration with complex data sources such as Prometheus, Graphite, and ElasticSearch.

This tutorial will guide you through installing and configuring Grafana on your Debian 11 server.

Prerequisites

To follow this tutorial you need:

  • Basic knowledge of the Linux command line.
  • A Debian 11 server with a non-root user with sudo privileges. You can get affordable, and powerful Debian servers from our website, and you can check out our How to access your server using SSH guide to learn how to access your server and create a sudo user.
  • The LEMP stack (Nginx, MariaDB, and PHP) installed on your server. Use our Installing LEMP on Ubuntu 22.04 LTS guide to set it up.

Note: You can use our LEMP 1-Click App to set up LEMP automatically when creating a server. Just visit our website, choose a server, and while prompted to choose the operating system, choose LEMP from the dropdown menu, complete your checkout, and in a couple of minutes our algorithms will take care of all the complex technicalities for you.

  • A TLS/SSL certificate, because Grafana can access sensitive information about your infrastructure.

Step 1: Updating the Package Cache and Installing Nano

Start by updating the packages in the package manager cache to the latest available versions using the following command:

sudo apt update

Next install the Nano editor which you'll later use in this article:

sudo apt -y install nano

Step 2: Install Grafana

To install Grafana, you will need to first add its APT repository. First get the official GPG key from the Grafana website and using the following command:

wget -q -O - https://packages.grafana.com/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/grafana.gpg > /dev/null

This downloads and stores the key in /usr/share/keyrings/grafana.gpg.

With the GPG key downloaded, add the Grafana repository to your APT sources using the following command:

echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

To use the repository, update the package index:

sudo apt update

Once the update is done, install Grafana with the following command:

sudo apt install grafana

Once the installation finishes, start the Grafana server:

sudo systemctl start grafana-server

Once started, check the Grafana server status with the systemctl status command:

sudo systemctl status grafana-server

You will receive the following output:

● grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; disabled; vendor preset: en>
     Active: active (running) since Sat 2023-01-28 16:46:37 UTC; 4s ago
       Docs: http://docs.grafana.org
   Main PID: 110381 (grafana-server)
      Tasks: 9 (limit: 19168)
     Memory: 44.0M
        CPU: 2.218s
     CGroup: /system.slice/grafana-server.service
             └─110381 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/>

Next, enable the Grafana server to start at boot:

sudo systemctl enable grafana-server

You should receive the following output:

Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /lib/systemd/system/grafana-server.service.

With this, Grafana is now successfully installed on your server.

Step 3: Logging in to Grafana

Now that you have Grafana installed on your server, you can visit the following URL to access the Grafana web interface:

http://your_server_IP_or_domain:3000

Remember to change your_server_IP_or_domain with your server's IP address or domain name.

Once you the page loads, you will see a login screen as follows:

Grafana Login

The default Grafana credentials are admin for the username and admin for the password. Once you enter these credentials and submit the form, you will be moved to a screen with a form for entering a new password for your admin account. Enter a strong password, re-enter it, and submit the form.

Once you secure your account, you'll be redirected to the Grafana dashboard.

Step 4: Disabling Grafana Signups and Anonymous Access

To further secure your Grafana set up, you need to disable an option that allows visitors to create user accounts and access the Grafana dashboard.

First, open Grafana's main configuration file:

sudo nano /etc/grafana/grafana.ini

Change the allow_sign_up directive from this:

# disable user signup / registration
;allow_sign_up = true

To the following:

# disable user signup / registration
allow_sign_up = false

Next, disable anonymous access. First, look for the following:

# enable anonymous access
;enabled = false

And change it to the following:

# enable anonymous access
enabled = false

This limits dashboard access to registered users only.

Save and close the file.

Restart Grafana:

sudo systemctl restart grafana-server

Check the status of the Grafana server:

sudo systemctl status grafana-server

The output should be as follows:

● grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; vendor preset: ena>
     Active: active (running) since Sat 2023-01-28 16:52:41 UTC; 3s ago
       Docs: http://docs.grafana.org
   Main PID: 111134 (grafana-server)
      Tasks: 14 (limit: 19168)
     Memory: 47.6M
        CPU: 1.223s
     CGroup: /system.slice/grafana-server.service
             └─111134 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/>

To verify that registrations have been disabled, visit your Grafana web interface like before:

http://your_server_IP_or_domain:3000

Move your cursor to the admin avatar on the lower-left of the screen directly above the question mark, then click Sign out.

Once your signed out, check that there is no Sign Up button on the page.

With this, the Grafana dashboard is now only accessible via accounts you register.

Congrats

You've successfully installed Grafana on your Debian 11 server, and you can now monitor your server. For more information on Grafana, check out their official website.

Important Note

What we’ve done in this article is suitable for testing purposes and personal use, whereas if you want to publish your site to production, and securely process your online transactions, we do suggest you check our Secure Your Site Using HTTPS with Self-Signed or CA SSL Certificates on Ubuntu 22.04 blog article, that explains in detail how to secure your site with SSL certificates

Reader Alert!

If you feel that the technical instructions in this tutorial are time-consuming, or beyond your expertise, you can choose a very convenient and practical solution, ready-made, fully and professionally tested, and developed by SSD Nodes (That is us 😊). Just visit our website, choose the server’s specifications that fit your needs, and while prompted to choose among the operating systems and the 1-Click Applications we have, choose Grafana from the dropdown menu, complete your checkout, and in a couple of minutes our algorithms will take care of all the technical aspects smoothly and effortlessly, just for you!

Bonus: All our 1-Click applications are now installed with an active HTTPS self-signed certificate!

Way more practical, smooth, and headacheless, isn’t it?

A note about tutorials: We encourage our users to try out tutorials, but they aren't fully supported by our team—we can't always provide support when things go wrong. Be sure to check which OS and version it was tested with before you proceed.

If you want a fully managed experience, with dedicated support for any application you might want to run, contact us for more information.

Leave a Reply