We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

29
2.044.462,70

Cart

Quantity 2.750,00
Quantity 19.800,00

Learn how to – Install Grafana with Prometheus on Rocky Linux 9|AlmaLinux 9

Learn how to – Install Grafana with Prometheus on Rocky Linux 9|AlmaLinux 9.

Monitoring is important in any environment as it helps system admins to check the performance and health of Linux servers. Today, there are many tools that are used to monitor systems. They include command line tools such as atop, top, htyop, apachetop e.t.c, log monitoring tools such as Logwatch, Swatch, MultiTail e.t.c, and infrastructure monitoring tools such as OpenNMS, SysUsage, Nagios, Cacti, Zabbix e.t.c. These tools are used depending on what the user wants to monitor.

What is Prometheus?

Prometheus is a free and open-source tool used for event monitoring and alerting. This tool was originally developed by SoundCloud in 2012 and promoted to the Cloud Native Computing Foundation in 2016.

Prometheus collects metrics storing metrics as time series data. Metrics can be defined as the numeric quantification that varies from time to time. The collected metrics are not only stored with a timestamp at which they were collected but also with key/value pairs.

Prometheus is preferred due to the following cool features:

  • It uses the PromQL query language which is flexible to leverage this dimensionality.
  • Single server nodes are autonomous and don’t rely on distributed storage
  • Multi-dimensional data model where time series data is identified by metric name and key/value pairs
  • Targets are discovered via service discovery or static configuration
  • It supports multiple graphing and dashboarding modes.
  • The time-series metrics collection happens via a pull model over HTTP

What is Grafana?

Once logs have been gathered by Prometheus or any other monitoring tool, you need to visualize them to identify the health and performance of the applications/servers.

Grafana is a cross-platform analytical and visualization tool. It provides context-rich visualizations, not only through graphs but also through other data presentation methods. Every dashboard can be customized to meet the needs of the particular software development project.

Using plugins, you can easily query, visualize, monitor, alert on and comprehend metrics from several data sources that include Google sheets, Amazon Timestream, ElasticSearch, InfluxDB, Prometheus, Graphite, PostgreSQL, MySQL e.t.c

The latest release version, Grafana v9.0 comes with a lot of many amazing features. Its main focus is to make data visualization, observability, and analytics easier and accessible for everyone.

The new features introduced in Grafana 9 are:

  • Prometheus query builder: due to the complexity of the PromQL query language, Grafana 9 introduces the new UI query builder from which you can easily compose and learn how to run Prometheus queries.
  • New heatmap panel: the old heatmap has been replaced with a modernized panel that uses the new panel option architecture. This new heatmap has the following enhancements:
    • Multiple orders of magnitude faster
    • Support for Prometheus sparse histograms
    • Supports changing the number of colors steps
    • Supports showing exemplars (traces) overlay
    • For un-bucketed data, it performs smarter auto bucket sizing
    • Allows filtering out bucket values close to but not exactly zero
  • Unified alerting is the default: In Grafana 9, unified alerting is now on by default. If you have been using legacy alerting in previous versions and you upgrade to this version, the legacy alerting will be replaced with unified alerting. Although unified alerting has been available since 2021, it now comes with feature parity with legacy alerting and many advanced benefits.
  • Expanding the navigation bar: for a better overview of the installed features and integrations, you can now expand the navigation bar in Grafana 9.
  • Explore to Dashboard: you can create panels/dashboards directly from Explore tab.
  • List of errors with trace IDs: to help one debug errors in Grafana, errors alerts include a trace ID. These alert errors can be accessed from the Profile

This guide demonstrates how to install Grafana 9 with Prometheus on Rocky Linux 9 / AlmaLinux 9.

Step 1 – Install Prometheus on Rocky Linux 9 / AlmaLinux 9

To install Prometheus on Rocky Linux 9 / AlmaLinux 9, follow the aid provided in the guide below;

You also need to install the Node and Blackbox Exporters and configure them to send data to Prometheus.

To verify that, access Prometheus using the URL http://IP_Address:9090 and proceed to the Status->Targets tab

Step 2 – Install Grafana 9 on Rocky Linux 9 / AlmaLinux 9

Once Prometheus has been installed, we need to install and configure Grafana 9 to get a better metrics visualization and observability.

Grafana provides 4 editions:

  • Grafana Enterprise
  • Grafana Enterprise (Beta)
  • Grafana OSS
  • Grafana OSS (Beta)

In this guide, we will install the Grafana OSS provide by the grafana package. This guide covers two methods on how to install Grafana on Rocky Linux 9 / AlmaLinux 9.

Option 1 – Using Yum Repositories

To install Grafana 9 on Rocky Linux 9 / AlmaLinux 9 using YUM repositories, you need to add the repositories to the system as shown:

sudo vim /etc/yum.repos.d/grafana.repo

Add the lines below to the file:

[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=0
enabled=1
gpgcheck=0
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

The Grafana installation fails with GPG key errors on Rocky Linux 9 / AlmaLinux 9. So I chose the disable the GPG check in the repo.

Install Garafana 9 with the command:

sudo yum install grafana

Dependency Tree:

Dependencies resolved.
============================================================================================================================================
 Package                           Architecture                   Version                             Repository                       Size
============================================================================================================================================
Installing:
 grafana                           x86_64                         9.0.7-1                             grafana                          76 M
Installing dependencies:
 chkconfig                         x86_64                         1.20-2.el9                          baseos                          162 k

Transaction Summary
============================================================================================================================================
Install  2 Packages

Total download size: 76 M
Installed size: 257 M
Is this ok [y/N]: y

Option 2 – Using RPM package

Grafana 9 can also be installed on Rocky Linux 9 / AlmaLinux 9 using an RPM package downloaded from the Grafana Downloads page.

You can also pull the package using wget as shown.

wget https://dl.grafana.com/oss/release/grafana-VERSION.x86_64.rpm

To install the downloaded package, issue the command:

sudo yum install grafana-*.x86_64.rpm

Start and Enable Grafana 9

Once the installation is complete, reload the system daemon with the command:

sudo systemctl daemon-reload

Now start and enable the service:

sudo systemctl start grafana-server
sudo systemctl enable grafana-server

Verify if the service is running:

$ systemctl status grafana-server
● grafana-server.service - Grafana instance
     Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: disabled)
     Active: active (running) since Mon 2022-08-15 11:59:36 CEST; 28s ago
       Docs: http://docs.grafana.org
   Main PID: 39728 (grafana-server)
      Tasks: 11 (limit: 23441)
     Memory: 42.8M
        CPU: 646ms
     CGroup: /system.slice/grafana-server.service
             └─39728 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=r

The Grafana server listens on port 3000 by default, verify this with the command:

$ sudo ss -plunt|grep grafana
tcp   LISTEN 0      4096               *:3000             *:*    users:(("grafana-server",pid=39728,fd=8))

Allow this port through the firewall:

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

To customize Grafana, edit the configuration file at /etc/grafana/grafana.ini to suit your preference.

Step 3 – Access the Grafana 9 Dashboard

To access the Grafana 9 dashboard, use the URL http://IP_Address:3000

You will be required to authenticate to the dashboard. The default credentials are:

username: admin
password: admin

On successful login, set a new password and you will be redirected to the below dashboard.

Step 4 – Add Prometheus Data Source to Grafana

Ensure Prometheus is installed by following the steps in the article below:

Now we need to add the Prometheus data source to Grafana 9. Click on Data sources-> Prometheus and proceed to provide the Prometheus URL as shown;

Click Save and test. If Prometheus is working, you will see this notification.

Now we need to create/import a dashboard to Grafana.

You can import the desired dashboard from Grafana.com. In this guide, we will import the popular Node Exporter dashboard since we already have Node Exporter configured on Prometheus.

We will use the Dashboard ID as shown:

Select Prometheus as the data source and import the dashboard.

You will be able to view graphs on Grafana 9 from Prometheus.

Voila!

Closing Thoughts

In this tutorial, we have learned how to install Grafana 9 with Prometheus on Rocky Linux 9 / AlmaLinux 9. We have gone through all the steps required to add Prometheus as a data source on Grafana. I hope this was informative.

See more:

Monitor Percona MySQL / Percona XtraDB Cluster With Prometheus & Grafana

How To Forward Logs to Grafana Loki using Promtail

Install Grafana on Kubernetes for Cluster Monitoring

29
2.044.462,70

Cart

Quantity 2.750,00
Quantity 19.800,00