How To Install Grafana on CentOS 9 Stream

Estimated reading: 5 minutes 368 views

This article is a step-by-step guide on how to install Grafana software on CentOS 9 Stream. Grafana is a popular open-source visualization and analytics monitoring software. It renders graphs, charts, and alerts when connected to supported data sources. It is commonly used with time series databases like Prometheus, SQL databases like MySQL logging, and document databases like Loki, etc. You can additionally install hundreds of plugins and dashboards from the official library.

1. Update your system

Before installing any tools on your CentOS 9, you should first update your RPM packages with YUM.

This step is optional but you may required to do it to keep your system safe.

# yum update
# yum upgrade

This step may take a couple of minutes if you haven’t updated your packages for a long time.

2. Add the Grafana repositories to your local YUM Repos

To be able to install Grafana with YUM, you need to add the official Grafana repositories to your local YUM-allowed repositories.

Create a new file named “grafana.repo”, and paste the following content in it.

# touch grafana.repo

Next, we will run the following command to add the repository to our /etc/yum.repos.d/grafana.repo file. The command should look like this.

# nano /etc/yum.repos.d/grafana.repo

Save your file and update your repositories one more time.

# yum update

3. Install Grafana with YUM

Now that your repositories are linked to Grafana official repositories, you are ready to install the latest version of Grafana on CentOS 9

To install Grafana with YUM, run the following command

# yum install grafana

Make sure to press “y” when you are asked if you want to install Grafana.

You will also be asked if you want to import the GPG key from Grafana, hit “y” to proceed with the installation.

4. Inspect your grafana-service systemd service

By default, Grafana created a systemd service for you.

First, you are going to make sure that the service was created, but you are also going to use it as a way to determine where files and folders are located on your host.

You will for example be given the data folder (where dashboards are stored) or the log folders to inspect your logs.

To inspect your Grafana service, run the following command

$ cat /usr/lib/systemd/system/grafana-server.service

Description=Grafana instance                                                                    
After=postgresql.service mariadb.service mysql.service                                          
ExecStart=/usr/sbin/grafana-server                                                  \           
                            --config=${CONF_FILE}                                   \           
                            --pidfile=${PID_FILE_DIR}/            \           
                            --packaging=deb                                         \           
                            cfg:default.paths.logs=${LOG_DIR}                       \           
                  ${DATA_DIR}                      \           
                            cfg:default.paths.plugins=${PLUGINS_DIR}                \           

This file is very important because it gives you much more information about your Grafana instance.

As you can see from this file :

  • The Grafana server binary is located at /usr/sbin/grafana-server.
  • The file that defines all the environment variables is located at /etc/sysconfig/grafana-server
  • The configuration file is given via the CONF_FILE environment variable.
  • The PID of the file is also determined by the PID_FILE_DIR environment variable.
  • Loggingdataplugins, and provisioning paths are given by environment variables.

Here’s the content of the environment variable file (etc/sysconfig/grafana-server)












# Only used on systemd systems

Also, a Grafana user and group were created for you on your instance.

Those credentials will be used to access and modify some of the files related to Grafana your CentOS 9

5. Start your grafana-server service

Start the Grafana service and enable it to start on boot.

# systemctl start grafana-server
# systemctl enable grafana-server

The Grafana service we want is the status.

# systemctl status grafana-server

Your Grafana server is now up and running on CentOS 9

6. Changing your firewall rules

Before configuring your Grafana server, you are going to open port 3000 via TCP on your server.

Grafana uses the port 3000 for Web Administration, as a consequence, the web interface may be inaccessible if you don’t open this port.

To open the port 3000 on CentOS 9, run this command

# firewall-cmd --add-port=3000/tcp --permanent
# firewall-cmd --reload

Make sure that everything is correctly set.

# firewall-cmd --list-all | grep ports

7. Launch Grafana v6 Web UI

Now that everything is configured properly, you should be able to have a look at the Grafana v6 Web UI.

To open the Grafana Web UI, navigate with your web browser.


As a reminder, here are all the defaults for Grafana:

The default port for Grafana is 3000.

You will be presented with this screen when launching the application for the first time.

The default login for Grafana is ‘admin’ and the default password is also ‘admin’.

When setting those credentials, you will be asked to change your password.

Choose a password, and click on ‘Save‘.

You should now see the default screen for Grafana


And that’s it! You now have Grafana set up with a basic configuration! Go ahead and explore the settings and what you have built, and then

Good luck!