How to Install Grafana Server on Debian 11 Open Source Monitoring

How to Install Grafana Server on Debian 11 Open Source Monitoring. Grafana is a graphically driven web interface for infrastructure metrics.

Firstly Grafana is an open-source server monitoring and graphing tool based on Graphite. It provides a web interface allowing users to monitor different resources like system and application logs, network connections, CPU/memory usage, disk usage, etc.

This article will discuss how you can install the Grafana server for open source operating system monitoring on Debian 11.

What is Grafana 

Secondly Grafana is a free, open source web-based graph visualization software for monitoring and analysing real time data on your servers, applications and networks.

In addition Grafana is a log analysis, time series database and dashboarding tool designed for monitoring the state of your infrastructure. It visualizes data from Graphite and InfluxDB, Prometheus, ElasticSearch, Kibana, MySQL, PostgreSQL, etc.

It was born out of a desire to create an interface that allows users to visualize data in a way that is both easy to understand and entertaining.

Moreover Grafana is written in JavaScript and Go, but it uses the popular InfluxDB database as the backend storage. It makes Grafana easy to customize, extend, and highly scalable with no additional cost and makes it easy to add more storage capacity as required.

It graphs your data and makes it interactive so you can explore its insights. You can set up a dashboard and get your data flowing directly into the browser. Grafana can be deployed as a standalone application or integrated with pre-existing monitoring systems like Nagios or Zabbix.

Additionally, it uses a web browser to connect to the server, so it’s easy to set up and use. It is also highly scalable with no additional cost, which makes it easy to add more storage capacity as required.

Open-source monitoring tool Grafana is an open-source alternative to the real-time dashboards found in big enterprise operating systems such as Prometheus, Zabbix, or Nagios.

Features of Grafana

Grafana has a lot to offer. Here are some of its notable features.

  • Visualization and dashboard templating.
  • Supports provisioning so you can automate setup using a script. 
  • It allows annotations.
  • Kiosk mode and playlists.
  • You can extend Grafana with custom plugins.
  • It has an alerting system and alert hooks.
  • Permissions and teams.
  • SQL data sources.
  • You can monitor your monitoring as it allows integration with other monitoring tools like Prometheus.
  • Grafana supports different authentication styles, such as LDAP and OAuth.

Advantages of Grafana

  • It is open source and easy to install.
  • Grafana has a simple and intuitive user interface that is easy to use.
  • It is platform independent. You can install it anywhere. It can be installed as a container or VM or hosted on any cloud.
  • A built-in HTTP server allows you to run Grafana from different machines on the same network.
  • Integration and extensions of Grafana are easy.
  • The alerting system alerts through email and Slack if any problem occurs.
  • Supports many different time series data sources, including InfluxDB, StatsD, Graphite, OpenTSDB, Prometheus, and many more.
  • Visualization of Grafana templates are highly convenient for analysis.

Follow this post to learn how to install Grafana Server on Debian 11 for Open Source Monitoring.

How to Install Grafana Server on Debian 11 Open Source Monitoring

Prerequisites

You will need:

  • Debian 11 system.
  • A user with root or sudo privileges.
  • A network connection.

Update Your System

It is always recommended to update your installed packages to make sure they are of the latest version.

				
					sudo apt-get update 
sudo apt-get upgrade 

				
			

Restart your system for the changes to take effect.

				
					sudo reboot
				
			

Resolve Dependencies

Install the dependency packages for Grafana server installation with the following command. 

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

Output:

				
					Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
apt-transport-https is already the newest version (2.2.4).
curl is already the newest version (7.74.0-1.3+deb11u1).
…

				
			

Add Grafana GPG Key

We need to add the Grafana repository to the sources list file as Grafana Server does not come by default in the Debian repository. To add a Grafana Server repository, we need to first add its GPG key with the following command.

				
					wget -q -O - https://packages.grafana.com/gpg.key |sudo apt-key add -

				
			

Output:

				
					Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

				
			

Add Grafana Server Repository To APT

Now, you can add the Grafana Server repository to the APT with the following command.

				
					sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
				
			

Update your system again to apply the changes.

				
					sudo apt-get update -y
				
			

You will see the following process in the output.

				
					…
Get:10 https://packages.grafana.com/oss/deb stable InRelease [12.1 kB]       
Ign:11 http://download.webmin.com/download/repository sarge InRelease
Hit:12 http://download.webmin.com/download/repository sarge Release
Get:13 https://packages.grafana.com/oss/deb stable/main amd64 Packages [32.4 kB]
…
				
			

Install Grafana Server

Once the server repository is added, you can install the Grafana server package using the following command.

				
					sudo apt-get install grafana -y
				
			

Output:

				
					Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  grafana
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
...
				
			

Manage Grafana Service 

Once the Grafana server is installed, the Grafana service will start automatically. You can verify this by checking the status of the Grafana service with the following command.

				
					sudo systemctl status grafana-server
				
			

Output:

				
					● grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-07-26 10:29:19 EDT; 1min 47s ago
       Docs: http://docs.grafana.org
   Main PID: 3387 (grafana-server)
      Tasks: 10 (limit: 6415)
     Memory: 48.2M
        CPU: 1.541s
     CGroup: /system.slice/grafana-server.service
             └─3387 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/run/grafana/grafana-server.pid >
…

				
			

If for some reason, the service has not started yet, you can start it manually with the following command.

				
					sudo systemctl start grafana-server
				
			

You can also enable the Grafana service to start at boot using the following command.

				
					sudo systemctl enable grafana-server
				
			

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.

				
			

Run the following command and verify that the Grafana service is listening at its default port of 3000.

				
					sudo ss -antpl | grep grafana
				
			

Output:

				
					LISTEN 0 4096 *:3000 *:* users:(("grafana-server",pid=3387,fd=8))
				
			

Install and Configure Nginx as a Reverse Proxy

You can use and communicate with the Grafana server through the port directly, but it is not secure or practical for the server. So next, you need to set up a reverse proxy for the Grafana server so that the server does not have to communicate with the users directly.

Install the Nginx Web Server

For that purpose, install the Nginx server using the following command.

				
					sudo apt-get install nginx -y
				
			

Output:

				
					Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  geoip-database libgeoip1 libnginx-mod-http-geoip libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libnginx-mod-stream-geoip nginx-common nginx-core
Suggested packages:
  geoip-bin fcgiwrap nginx-doc
…
				
			

Configure the Nginx Web Server

				
					sudo nano /etc/nginx/conf.d/grafana.conf
				
			

Add the following lines of code to the file.

				
					server {
        server_name grafana.exampledomain.com;
        listen 80 ;
        access_log /var/log/nginx/grafana.log;

        location / {
                proxy_pass http://localhost:3000;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Host $host:$server_port;
                proxy_set_header X-Forwarded-Server $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

				
			

Save and close the file. Next, check the Nginx configuration.

				
					sudo nginx -t
				
			

See the following output.

				
					nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

				
			

Now restart and ensure the Nginx service is running properly using the following commands.

				
					sudo systemctl restart nginx
sudo systemctl status nginx

				
			

Allow the Grafana Server Through the Firewall

You have to configure to allow ports 22 and 80 through the firewall by running the following commands.

				
					sudo ufw allow 80/tcp
sudo ufw allow 22/tcp

				
			

Enable and reload the firewall for the changes to take effect.

				
					sudo ufw enable
sudo ufw reload

				
			

Verify the configurations by checking the firewall status with the following command.

				
					sudo ufw status
				
			

The Output:

				
					Status: active

To Action From
-- ------ ----
22/tcp ALLOW Anywhere                                  
80/tcp ALLOW Anywhere                  
22/tcp (v6) ALLOW Anywhere (v6)                       
80/tcp (v6) ALLOW Anywhere (v6)            
…

				
			

Access the Grafana Dashboard

Finally, you can access the Grafana Web UI from the browser by using the following URL.

				
					http://grafana..com
				
			

You will see the Grafana Login screen. Click the Login button after entering the default admin username as admin and password as admin.

You will see the password reset screen after you have logged in. Proceed to change the admin password and press the Submit button. 

The screen should display the following Grafana server dashboard. 

You can see the Tutorial and Data Sources options on the dashboard. You can now link the external data source to the Grafana server and begin monitoring it from a single location.

That’s it about How to Install Grafana Server on Debian 11 Open Source Monitoring.

How to Install Grafana Server on Debian 11 Open Source Monitoring Conclusion

In this article, you have learned about Grafana open source monitoring and its installation process on a Debian 11 system. In addition, you have learned how to utilize the Nginx reverse proxy to secure the Grafana port.

To sum up Grafana is an open-source data visualization tool that can be used to monitor various aspects of your network. It can be used to monitor, visualize, and alert on CPU, memory and disk usage; notifications for alerts like Syslog, SNMP traps; etc.

It’s designed to give users a quick, intuitive way to visualize and analyze their data in real-time.

You can explore other monitoring solutions like this in our monitoring section.

Avatar for Sobia Arshad
Sobia Arshad

Information Security professional with 4+ years of experience. I am interested in learning about new technologies and loves working with all kinds of infrastructures.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x