Day 73: Setup Grafana in your local environment on AWS EC2.

Day 73: Setup Grafana in your local environment on AWS EC2.

Hope you are now clear on the basics of Grafana, like why we use it, where we use it, what we can do with it, and so on.

Now, let's do some practical stuff.

Introduction:

📉Grafana is an open source interactive data-visualization platform created by Grafana Labs that allows users to view their data through charts and graphs that are combined into a single dashboard (or numerous dashboards!) for easier interpretation and understanding.

📈We can host Grafana ourselves using AWS Managed Services or have creators host it for you. Grafana runs the procedure on our server or computer, and we may view the UI using our browser. The dashboard can display data in the form of graphs, heat maps, single statistics, or charts. Here is example how charts looks like,

📉You may also query and trigger alerts on your data and metrics from wherever they are stored, whether in traditional server environments, Kubernetes clusters, or multiple cloud services.

📈Today, practically every application architecture consists of a number of distinct applications, each performing a unique task and working together to achieve a shared goal. As such, the stability and reliability of your infrastructure would greatly depend on the performance of each application within that infrastructure.

📉Understanding the state of these applications is vital to keeping your systems in the best shape possible. This is done by monitoring our applications, or, in other words, collecting data about these applications that would inform you of their current state at all times. The larger your stack, the more applications you must monitor to keep your infrastructure healthy.

📈This would result in the collection of significant volumes of performance data for your application. It would therefore take a significant amount of effort to parse through and make sense of this data, which is not an easy undertaking without the right tool. Grafana was made exactly for this purpose!

Task 1:

Setup Grafana in Your Local Environment on AWS EC2

We’ll follow the steps outlined in the Official Grafana Documentation

Launch an AWS EC2 Instance

  1. Log in to your AWS Management Console and navigate to the EC2 service.

  2. Click on “Launch Instance” to create a new instance and select an appropriate Amazon Machine Image (AMI) for your EC2 instance. Choose an image that supports Grafana, like Amazon Linux or Ubuntu.

  3. Choose an instance type based on your requirements and configure instance details such as the VPC, subnet, security group, and any other necessary settings.

  4. Review and launch the instance.

Connect to Your EC2 Instance

Once the instance is launched, select it from the EC2 dashboard.

Install Grafana

Complete the following steps to install Grafana from the APT repository:

⫸ To install the required packages and download the Grafana repository signing key, run the following commands:

sudo apt update

sudo apt-get install -y apt-transport-https software-properties-common wget

#import gpg keys
sudo mkdir -p /etc/apt/keyrings/
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null

⫸ To add a repository for stable releases, run the following command:

echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

⫸ To install Grafana OSS, run the following command:

 # Installs the latest OSS release:
 sudo apt-get install grafana

Start and Enable Grafana Service

⫸ To start and enable the service, run the following commands:

sudo systemctl start grafana-server.service
sudo systemctl enable grafana-server.service
sudo systemctl status grafana-server.service

Grafana server runs on TCP port 3000. We will need to allow this port in the EC2 instance's security group.

⫸ Click on "Edit inbound rule" in the security group.

Access Grafana Web Interface

⫸ By default, Grafana listens on port 3000. Use this public IP along with port 3000 to access the Grafana welcome page.

Log in to Grafana

  1. On the sign-in page, enter admin for your username and password.

  2. The first time you access Grafana, you will be prompted to set up an admin password.

  3. Set your admin password and log in with the default username “admin” and the password you just set.

    ⫸ Now, we have logged into Grafana.

    Explore the Grafana interface and start creating your own dashboards to visualize and monitor data from various data sources.

Congratulations! You’ve successfully set up Grafana in your local environment on an AWS EC2 instance.

Now, you can leverage Grafana’s powerful visualization capabilities to monitor and analyze your data efficiently.

Thank you for reading 👍 Happy Learning😊😊

If you liked this article , then click on 👏👏 do follow for more interesting 📜articles. Hope you find it helpful✨✨

Connect on 👉 chandana LinkedIn