• About Us
  • Contact Us

SETTING UP GRAFANA, PROMETHEUS, AND NODE EXPORTER ON EC2 INSTANCES

Monitoring your infrastructure is crucial for maintaining system performance and ensuring smooth operations. This guide will walk you through setting up Grafana, Prometheus, and Node Exporter on AWS EC2 instances. By the end of this tutorial, you’ll have a robust monitoring setup to visualize and analyze system metrics in real-time.

OVERVIEW OF TOOLS:                              

GRAFANA:

An open-source data visualization platform that allows users to create interactive dashboards to visualize data from various sources, like Prometheus. While Prometheus can generate basic graphs, we use Grafana because it provides advanced visualizations, better customization, and rich alerting options. Grafana can display data from multiple sources in a single dashboard, providing a more centralized monitoring experience.

PROMETHEUS:

An open-source monitoring toolkit designed to collect, store and display data. It works by scraping metrics from targets, like Node Exporter. These metrics are collected by Prometheus through HTTP endpoints, providing valuable insights into the health and performance of the system.

NODE EXPORTER:

A Prometheus exporter that collects system-level metrics (e.g., CPU, memory, disk usage) from Linux or Unix-based machines and exposes them in a format Prometheus can scrape. It’s a critical component for monitoring infrastructure with Prometheus.

PREREQUISITES:

  • Two EC2 instances with Elastic IPs assigned.
  • Basic understanding of AWS and Linux commands.

STEPS TO SET UP MONITORING ON EC2 INSTANCES:

1. LAUNCH 1st EC2 INSTANCE:

Launch an EC2 instance for hosting Prometheus and Grafana.

  • Open required ports in the security group:
    • 9090 for Prometheus
    • 3000 for Grafana
  • Associate an Elastic IP with this instance.

2. INSTALL PROMETHEUS:

Download Prometheus:

Download And Install Prometheus from the resource provided at the end of blog.

(This Following Command Is For Linux Instance)

Unzip The Prometheus File:

Now Go To Location:

Here We Will Create The File:

In This File We Will Paste The Following Data:

Add Target In Prometheus.Yml:

Here Below Target Add A Line:

(Here: 52.221.3.208 is example ip)

Now We Will Restart The Daemon:

Start The Prometheus Service:

Enable The Prometheus Service:

3. INSTALL GRAFANA:

Now install Grafana from provided source.

Above command will install Grafana on your server.

After running the above command, we will be provided with the other commands as well to enable and start Grafana.

Grafana installation is simple.

Now start Grafana:

Now Enable Grafana:

4. LAUNCH 2nd EC2 INSTANCE:

Launch an EC2 instance for hosting Node Exporter.

  • Open port 9100 in the security group.

5. Install Node Exporter

(Now install node exporter from provided link follow same process for Node Exporter as of Prometheus)

Create a Service File:

Paste the following content:

Start Node Exporter Service:

6. CONFIGURE PROMETHEUS IN THE BROWSER:

In front of 2nd EC2 instance we should get a 1.

Now Enter The Following Command:

(this will show cpu utilization metrics coming from node exporter)

7. CONFIGURE GRAFANA IN BROWSER:

  1. Access Grafana using the Elastic IP and port 3000.
  2. Username: admin
  3. Password: admin

Here Follow These Steps:

Here In “Prometheus server URL” paste the same IP address which you pasted in Prometheus browser.

Now click,
Dashboards<New<Add Visualization<Prometheus.

7.VIEW THE DASHBOARDS IN GRAFANA:

Finally, we can see the dashboard CPU utilization metrics after creating the dashboard.

Resources

Conclusion

Setting up Grafana, Prometheus, and Node Exporter on EC2 instances provides a powerful monitoring solution for your infrastructure. By following the steps outlined in this guide, you’ll gain valuable insights into your system’s performance and health, enabling you to proactively address potential issues.