How to install Grafana on EC2 Amazon Linux 2

Grafana is an open source software that specializes in creating graphs and visualizations for users to easily understand the time-series data.

On this step-by-step guide, we will be launching an EC2 Instance with Amazon Linux 2 as the operating system, then install and run Grafana.

EC2 Instance Setup

Launch an EC2 Instance using the Amazon Linux 2 AMI.

For reference here are the settings of my EC2 Instance.

AMIAmazon Linux 2
Instance Typet2.micro (free tier) or
t3a.nano (cheapest)
Storage8GB General Purpose SSD (gp2)
TagsKey: Name
Value: Grafana-Server
Security GroupSee below (EC2 Security Group Setup)

Note: This post is about installing Grafana on Amazon Linux 2. Launching an EC2 Instance will not be discussed here.

EC2 Security Group Setup

For the EC2 Instance Security Group I opened SSH (22) and default Grafana port (3000) to the internet (0.0.0.0/0).

Grafana Installation

SSH to the target EC2 Instance.

 ssh [email protected] -i GrafanaKeyPair.pem

Since this is the first time we are using the EC2 Instance we need to update all installed packages.

sudo yum update -y

Then we add a new YUM respository for the operating system to know where to download Grafana. The command below will use nano.

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

Add the lines below to grafana.repo. This setting will install to the Open Source version of Grafana.

[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

Install Grafana.

sudo yum install grafana

There will be around 3 times the system will ask if it is okay to download the grafana packages. Just press Y and enter everytime to allow download and installation.

Reload the systemd to load the new settings. Start Grafana Server, then check for its status.

sudo systemctl daemon-reload

Start the Grafana Server.

sudo systemctl start grafana-server

Check the status of Grafana Server

sudo systemctl status grafana-server

Status output should show that grafana-server is active (running).

Run the command below to make sure that Grafana will start upon booting our Amazon Linux 2 instance.

sudo systemctl enable grafana-server.service

Testing Grafana

Visit the newly installed Grafana Server by visiting the Public IP of the EC2 Instance on port 3000.

18.206.59.38:3000

This will then redirect to the login screen of Grafana.

See default username and password below.

Usernameadmin
Passwordadmin

On first login Grafana will requires to change the admin password. Input the desired password (except admin) and click Save.

This will move to the default Grafana Welcome Grafana page.

We can now add Data Sources, Dashboards, Users or Explore plugins and many more.

We have now succesfully installed Grafana on EC2 Instance running in Amazon Linux 2.

If you have any questions or issues encountered let me know in the comments below.

2 thoughts on “How to install Grafana on EC2 Amazon Linux 2”

  1. Bonjour ! Très bon article, même si il y aurais quelques petits points à rajouter, l’article reste super intéressant.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.