Prometheus and Grafana Monitoring Setup on Ubuntu (Step-by-Step) - Part1

 Monitoring Linux Servers Using Prometheus and Grafana (AWS & On-Prem)

Monitoring is a critical part of system reliability. In this guide, we will set up Prometheus and Grafana to monitor multiple Linux servers (AWS EC2 or on-prem) using Node Exporter.


🔹 What is Prometheus?

Prometheus is an open-source monitoring and alerting tool.

Key Features:

  • Free and open source

  • Cloud-agnostic (works with AWS, Azure, GCP, and on-prem)

  • Platform dependent (runs on Linux systems)

  • Stores metrics in TSDB (Time Series Database)

  • Uses PromQL (Prometheus Query Language) for querying metrics

  • Automatically provides basic dashboards

Default Port:

  • Prometheus UI: 9090


🔹 What is Grafana?

Grafana is an open-source visualization tool used to display metrics collected by Prometheus.

Key Features:

  • Rich and interactive dashboards

  • Supports multiple data sources

  • Widely used for monitoring and observability

Default Port:

  • Grafana UI: 3000

Default Credentials:

  • Username: admin

  • Password: admin


🔹 What is Node Exporter?

Node Exporter collects system-level metrics such as:

  • CPU usage

  • Memory utilization

  • Disk and filesystem metrics

  • Network statistics

Prometheus pulls these metrics from Node Exporter.

Default Port:

  • Node Exporter: 9100


🔹 Architecture Overview

  • 1 Monitoring Server

    • Runs Prometheus + Grafana

  • Multiple Target Servers

    • Run Node Exporter

  • Prometheus pulls metrics from Node Exporter

  • Grafana visualizes the metrics using dashboards


Step 1: Create Monitoring Server (AWS EC2)

Create an EC2 instance for Prometheus and Grafana.

Instance Details:

  • AMI: Ubuntu

  • Instance Name: MonitoringServer (name can be customized)

  • Key Pair: Choose or create one

Security Group Rules:

ProtocolPortSource
HTTP800.0.0.0/0
Custom TCP90900.0.0.0/0
Custom TCP91000.0.0.0/0
Custom TCP30000.0.0.0/0

Launch the instance and connect to it using SSH.


Step 2: Install Prometheus, Grafana & Node Exporter

We will use a ready-made automation script.

Run the Following Commands:

git clone https://github.com/methleshsingh99/allSetup.git cd allsetup ls chmod +x pegion-ubuntu.sh sudo ./pegion-ubuntu.sh

Command Explanation:

  • git clone – Downloads the setup scripts from GitHub

  • cd allsetup – Enters the project directory

  • ls – Verifies the presence of pegion-ubuntu.sh

  • chmod +x – Grants execute permission to the script

  • sudo ./pegion-ubuntu.sh – Installs Prometheus, Grafana, and Node Exporter

⏱️ Installation usually completes within 20–30 seconds, though it may take up to 2 minutes depending on network speed.


Step 3: Verify Installation

Open your browser and check:

  • Prometheus:
    http://<Monitoring_Server_Public_IP>:9090

  • Grafana:
    http://<Monitoring_Server_Public_IP>:3000

  • Node Exporter:
    http://<Monitoring_Server_Public_IP>:9100

If Node Exporter is working, you will see output containing:

# HELP # TYPE

Step 4: Create Target Servers to Monitor

Now create EC2 instances that you want to monitor.

Instance Details:

  • AMI: Ubuntu

  • Instance Name: Server_01, Server_02, etc.

  • Key Pair: Same or different

Security Group Rules:

ProtocolPortSource
HTTP800.0.0.0/0
Custom TCP91000.0.0.0/0

Launch the instances and connect to them.


Step 5: Install Node Exporter on Target Servers

Run the following commands on each server:

git clone https://github.com/RAHAMSHAIK007/all-setups cd all-setups ls chmod +x nodeexporter.sh sudo ./nodeexporter.sh

Command Explanation:

  • git clone – Downloads Node Exporter installation scripts

  • cd all-setups – Moves into the repository

  • ls – Confirms the script exists

  • chmod +x – Makes the script executable

  • sudo ./nodeexporter.sh – Installs and starts Node Exporter


Step 6: Verify Node Exporter

Open a browser and go to:

http://<Target_Server_Public_IP>:9100

If successful, metrics will be displayed in text format.


✅ Final Outcome

  • Prometheus collects metrics from all servers

  • Grafana visualizes those metrics

  • Node Exporter runs on every monitored server

  • One monitoring server can monitor multiple servers

Comments

Popular posts from this blog

Managing Amazon EBS Volumes and Snapshots Across Regions

Git for Beginners: Complete Guide from Installation to First Push on GitHub

AWS - Amazon Web Services