Grafana is an open source platform for monitoring and observability. It allows you to visualize, query, alert on metrics stored in various storage backends. With Grafana you can create, explore, and share your visualization dashboards with your team, friends or open source community and foster a data driven culture. In this article we will be installing Grafana 7 on Amazon Linux 2 server.

In our recent article on monitoring we covered the installation and configuration of Prometheus monitoring tool on Amazon Linux 2. This guide is a continuation of our monitoring series. Some notable features of Grafana Monitoring platform are:

  • Visualize: Fast and flexible client side graphs with a multitude of options. Panel plugins for many different way to visualize metrics and logs.
  • Dynamic Dashboards: Create dynamic & reusable dashboards with template variables that appear as dropdowns at the top of the dashboard.
  • Explore Metrics: Explore your data through ad-hoc queries and dynamic drilldown. Split view and compare different time ranges, queries and data sources side by side.
  • Explore Logs: Experience the magic of switching from metrics to logs with preserved label filters. Quickly search through all your logs or streaming them live.
  • Alerting: Visually define alert rules for your most important metrics. Grafana will continuously evaluate and send notifications to systems like Slack, PagerDuty, VictorOps, OpsGenie.
  • Mixed Data Sources: Mix different data sources in the same graph! You can specify a data source on a per-query basis. This works for even custom datasources.

Install Grafana 7 on Amazon Linux 2

The steps used to install Grafana on Amazon Linux 2 server are straightforward. You’ll add a YUM repository and pull the latest software packages from the repository using yum package manager. There are two editions of Grafana that can be installed on Amazon Linux 2 machine.

  1. Grafana Enterprise
  2. Grafana OSS

The repository URL for the Enterprise edition is https://packages.grafana.com/enterprise/rpm and for the open source edition it is https://packages.grafana.com/oss/rpm.

Add Grafana YUM repository to Amazon Linux 2

Add a new file to your YUM repo using the method of your choice. I’ll use below single line commands to create a repository file in /etc/yum.repos.d/grafana.repo.

Adding Enterprise repository:

sudo tee /etc/yum.repos.d/grafana.repo<<EOF
[grafana]
name=grafana
baseurl=https://packages.grafana.com/enterprise/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF

Adding OSS repository:

sudo tee /etc/yum.repos.d/grafana.repo<<EOF
[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
EOF

You can cat the file contents to confirm it is created as desired.

$ cat /etc/yum.repos.d/grafana.repo

If you run the yum repolist command, it should return output similar to below.

$ sudo yum repolist

Agree to retrieve repository GPG key.

Retrieving key from https://packages.grafana.com/gpg.key
Importing GPG key 0x24098CB6:
 Userid     : "Grafana <[email protected]>"
 Fingerprint: 4e40 ddf6 d76e 284a 4a67 80e4 8c8c 34c5 2409 8cb6
 From       : https://packages.grafana.com/gpg.key
Is this ok [y/N]: y

Install Grafana 7 on Amazon Linux 2

With the repository created and confirmed to be working, proceed to install Grafana 7 on Amazon Linux 2:

sudo yum install -y grafana

Installed package details.

$ rpm -qi grafana
Name        : grafana
Version     : 7.2.0
Release     : 1
Architecture: x86_64
Install Date: Mon 05 Oct 2020 06:16:04 PM UTC
Group       : default
Size        : 171426337
License     : "Apache 2.0"
Signature   : RSA/SHA256, Wed 23 Sep 2020 12:20:27 PM UTC, Key ID 8c8c34c524098cb6
Source RPM  : grafana-7.2.0-1.src.rpm
Build Date  : Wed 23 Sep 2020 12:19:56 PM UTC
Build Host  : 2d74f39865d4
Relocations : /
Packager    : [email protected]
Vendor      : Grafana
URL         : https://grafana.com
Summary     : Grafana
...

Start and enable grafana service.

sudo systemctl enable --now grafana-server

Use systemctl command to check status of the service.

$ systemctl status grafana-server.service
● grafana-server.service - Grafana instance
   Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2020-10-05 18:17:44 UTC; 2min 33s ago
     Docs: http://docs.grafana.org
 Main PID: 1165 (grafana-server)
   CGroup: /system.slice/grafana-server.service
           └─1165 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=rpm cfg:default.paths.lo...

Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Executing migration" logger=migrator id="add unique index ...th_token"
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Executing migration" logger=migrator id="add unique index ...th_token"
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Executing migration" logger=migrator id="create cache_data table"
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Executing migration" logger=migrator id="add unique index ...ache_key"
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Created default admin" logger=sqlstore user=admin
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Starting plugin search" logger=plugins
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="Registering plugin" logger=plugins name="Direct Input"
Oct 05 18:17:44 amazon-linux grafana-server[1165]: t=2020-10-05T18:17:44+0000 lvl=info msg="External plugins directory created" logger=plugins directo...a/plugins
Oct 05 18:17:44 amazon-linux systemd[1]: Started Grafana instance.

Access Grafana Web console

If you have a running firewalld service make sure you allow port 3000/tcp.

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

Open a web browser to access Grafana web console – http://[grafana_server_hostname_or_IP_address:3000/]

The default login credentials are:

Username: admin
Password: admin

Reset admin password after initial login.

Your Grafana server is now ready for data visualization.

Keep visiting our website to get latest articles on monitoring and other technologies.

Similar guides:

How To Install Prometheus on Amazon Linux 2

Install Zabbix 5 LTS With Nginx on Oracle Linux

LEAVE A REPLY

Please enter your comment!
Please enter your name here

twelve + 7 =