How to install Grafana on Rocky Linux 9.2

To install Grafana in Rocky Linux 9.2

Introduction:

Grafana is an open-source data visualization and monitoring tool used for analyzing and monitoring time-series data that provides a rich set of features and a flexible and customizable platform for creating interactive dashboards and graphs. Grafana supports a wide range of data sources, including popular databases like MySQL, PostgreSQL, and Prometheus, as well as cloud services like AWS CloudWatch and Google Analytics.

Installation steps:

Step 1: Check the OS version by using the below command

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.2 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.2 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.2"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

Step 2: Create a .repo file by using vim text editor.

[root@Linuxhelp ~]# vim /etc/yum.repos.d/grafana.repo
Add following directives in this file.
[grafana]
name=grafana
baseurl=https://rpm.grafana.com
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://rpm.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
exclude=*beta*

Step 3: After adding Grafana repository, rebuild your yum cache by using the following command.

[root@Linuxhelp ~]# dnf makecache
grafana                                                                                                                                                                       627  B/s | 629  B     00:01
grafana                                                                                                                                                                       1.9 kB/s | 2.4 kB     00:01
Importing GPG key 0x2CF3C0C6:
 Userid     : "Grafana Labs <engineering@grafana.com>"
 Fingerprint: 0E22 EB88 E39E 1227 7A77 60AE 9E43 9B10 2CF3 C0C6
 From       : https://rpm.grafana.com/gpg.key
Is this ok [y/N]: y
grafana                                                                                                                                                                       7.0 MB/s |  37 MB     00:05
Rocky Linux 9 - BaseOS                                                                                                                                                        2.7 kB/s | 4.1 kB     00:01
Rocky Linux 9 - BaseOS                                                                                                                                                        149 kB/s | 1.9 MB     00:12
Rocky Linux 9 - AppStream                                                                                                                                                     4.4 kB/s | 4.5 kB     00:01
Rocky Linux 9 - AppStream                                                                                                                                                     2.1 MB/s | 7.1 MB     00:03
Rocky Linux 9 - Extras                                                                                                                                                        3.1 kB/s | 2.9 kB     00:00
Rocky Linux 9 - Extras                                                                                                                                                        5.4 kB/s |  10 kB     00:01
Metadata cache created.

Step 4: Check the information about Grafana software package by using the below command.

[root@Linuxhelp ~]# dnf info grafana.x86_64
Last metadata expiration check: 0:00:16 ago on Thu 10 Aug 2023 01:03:04 PM IST.
Available Packages
Name         : grafana
Version      : 10.0.3
Release      : 1
Architecture : x86_64
Size         : 79 M
Source       : grafana-10.0.3-1.src.rpm
Repository   : grafana
Summary      : Grafana
URL          : https://grafana.com
License      : AGPLv3
Description  : Grafana

Step 5: Install Grafana by using the below command.

[root@Linuxhelp ~]# dnf install -y grafana
Last metadata expiration check: 0:01:05 ago on Thu 10 Aug 2023 01:03:04 PM IST.
Dependencies resolved.
==============================================================================================================================================================================================================
 Package                                          Architecture                                    Version                                              Repository                                        Size
==============================================================================================================================================================================================================
Installing:
 grafana                                          x86_64                                          10.0.3-1                                             grafana                                           79 M

Transaction Summary
==============================================================================================================================================================================================================
Install  1 Package

Total download size: 79 M
Installed size: 292 M
Downloading Packages:
grafana-10.0.3-1.x86_64.rpm                                                                                                                                                   6.0 MB/s |  79 MB     00:13
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                         6.0 MB/s |  79 MB     00:13
grafana                                                                                                                                                                       4.7 kB/s | 2.4 kB     00:00
Importing GPG key 0x2CF3C0C6:
 
Userid     : "Grafana Labs <engineering@grafana.com>"
 Fingerprint: 0E22 EB88 E39E 1227 7A77 60AE 9E43 9B10 2CF3 C0C6
 From       : https://rpm.grafana.com/gpg.key
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                      1/1
  Installing       : grafana-10.0.3-1.x86_64                                                                                                                                                              1/1
  Running scriptlet: grafana-10.0.3-1.x86_64                                                                                                                                                              1/1
### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd
 sudo /bin/systemctl daemon-reload
 sudo /bin/systemctl enable grafana-server.service
### You can start grafana-server by executing
 sudo /bin/systemctl start grafana-server.service

POSTTRANS: Running script

  Verifying        : grafana-10.0.3-1.x86_64                                                                                                                                                              1/1

Installed:
  grafana-10.0.3-1.x86_64

Complete!

Step 6: Enable and start Grafana service by using the below command.

[root@Linuxhelp ~]# systemctl enable --now grafana-server
Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /usr/lib/systemd/system/grafana-server.service.
[root@Linuxhelp ~]# systemctl start --now grafana-server

Step 7: Check the status of Grafana service for any possible errors by using the below Command.

[root@Linuxhelp ~]# systemctl status grafana-server
● grafana-server.service - Grafana instance
     Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; preset: disabled)
     Active: active (running) since Thu 2023-08-10 13:04:59 IST; 36s ago
       Docs: http://docs.grafana.org
   Main PID: 4144 (grafana)
      Tasks: 8 (limit: 22877)
     Memory: 77.8M
        CPU: 5.242s
     CGroup: /system.slice/grafana-server.service
             └─4144 /usr/share/grafana/bin/grafana server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=rpm cfg:default.paths.logs=/var/log/grafana cfg:default>

Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=modules t=2023-08-10T13:04:59.118496966+05:30 level=warn msg="No modules registered..."
Aug 10 13:04:59 Linuxhelp systemd[1]: Started Grafana instance.
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=grafanaStorageLogger t=2023-08-10T13:04:59.123587041+05:30 level=info msg="storage starting"
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=http.server t=2023-08-10T13:04:59.129310037+05:30 level=info msg="HTTP Server Listen" address=[::]:3000 protocol=http subUrl= socket=
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=ngalert.state.manager t=2023-08-10T13:04:59.129747733+05:30 level=info msg="Warming state cache for startup"
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=ngalert.state.manager t=2023-08-10T13:04:59.130080569+05:30 level=info msg="State cache has been initialized" states=0 duration=333.018µs
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=ticker t=2023-08-10T13:04:59.130277156+05:30 level=info msg=starting first_tick=2023-08-10T13:05:00+05:30
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=ngalert.multiorg.alertmanager t=2023-08-10T13:04:59.134973279+05:30 level=info msg="starting MultiOrg Alertmanager"



Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=grafana.update.checker t=2023-08-10T13:04:59.348724213+05:30 level=info msg="Update check succeeded" duration=216.078901ms
Aug 10 13:04:59 Linuxhelp grafana[4144]: logger=plugins.update.checker t=2023-08-10T13:04:59.568111899+05:30 level=info msg="Update check succeeded" duration=434.227259ms
lines 1-21/21 (END)

Step 8: Open web browser and search our server ip address.

http://192.168.6.130:300

Login to Grafana dashboards by using default username/password i.e. admin/admin

Set a new strong password for your Grafana admin user or you can skip.

You have successfully login to Grafana web application.

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to Install Grafana on Rocky Linux 9.2. Your feedback is much welcome.

FAQ
Q
How do you restart Grafana?
A
systemctl restart grafana-server
Q
How do you check if the Grafana service is running or not?
A
You can validate that Grafana is running by checking the service’s status command as given below:
systemctl status grafana-server
Q
How do you upgrade Grafana?
A
If you have installed Grafana from the APT repository then every time you run the apt-get upgrade command it will automatically update your software to the latest version.
Q
Where does Grafana save dashboards?
A
The folder /var/lib/grafana is the default location where all Grafana dashboards are saved.
Q
What is Grafana used for?
A
Grafana is used for a variety of data visualization use cases including but not limited to server monitoring, performance testing, windows host monitoring, and Docker monitoring as well as for building metrics reporting dashboards in general.