# 🚀 Setting Up Prometheus and Grafana Easily

Monitoring your infrastructure doesn’t have to be complicated. In this guide, I’ll show you how to set up **Prometheus and Grafana** in the easy way. Whether you're a beginner or just looking for a quick demo environment, this setup will get you up and running with real-time metrics, dashboards, and multi-instance monitoring in under 15 minutes.

### Prerequisites

Before we begin, I’ve already launched **three EC2 instances** (Ubuntu 22.04) for this demo:

* `instance-01` (Main Prometheus + Grafana Server)
    
* `instance-02` (Node Exporter)
    
* `instance-03` (Node Exporter)
    

All instances follow the same initial setup.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746017882095/f0cae32f-9cba-455f-badd-40331315325e.png align="center")

### Step 1: Initial Setup on All Instances

SSH into each EC2 instance and run the following:

```plaintext
sudo suapt update -y
git clone https://github.com/linnlattoo-cloud/prometheus_grafana.git
cd prometheus_grafana
chmod +x *.sh
```

This prepares the environment by cloning the necessary scripts and ensuring all `.sh` files are executable.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746017997172/5ae9d7f9-4005-461e-af8a-b385295db0a6.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018044807/0786eec6-6ca9-419d-96b5-4c0311e5da4c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018057215/5767b52f-fa7c-43f7-b4ac-ccc3fee2f7fa.png align="center")

### Step 2: Configure instance-01 (Main Monitoring Server)

On `instance-01`, execute the installation scripts **in order**:

```plaintext
./01…
./02…
./03…
./04…
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018393559/ed362770-c141-47ce-a6f8-4a0f3cc5f126.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018403755/475214d7-7075-4deb-88ce-98b082cb1fcc.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018417246/617200a8-d891-4bd5-869d-80aea531ec7b.png align="center")

Once done, you can now access the dashboards:

* **Prometheus:** `http://<instance-01-ip>:9090`
    
* **Grafana:** `http://<instance-01-ip>:3000`
    

🔐 Default Grafana credentials:

* Username: `admin`
    
* Password: `admin`
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018483147/4ca9fc73-dbd1-4aaf-82d2-2c31f693b29d.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018490114/9590a530-7ce3-4e13-b4e8-6c429fd38e47.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018509471/db851b9a-e7fe-453f-8167-f76035bb17f3.png align="center")

### Step 3: Configure instance-02 and instance-03 (Node Exporters)

For the other two instances, just set up Node Exporter <mark>by running 03…sh file</mark>:

```plaintext
./03…
```

This installs Node Exporter so they can be monitored by Prometheus.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018662377/88d20586-1662-4600-b1b0-172c240ecd16.png align="center")

### Step 4: Connect All Targets in Prometheus

Back in `instance-01`, open the Prometheus configuration file:

```plaintext
sudo vi /etc/prometheus/prometheus.yml
```

Under the `scrape_configs` section, add all three instances like this:

```plaintext
- job_name: 'remote_collector' 
  scrape_interval: 10s 
  static_configs: 
    - targets: ['instance-01-ip:9100', 'instance-02-ip:9100', 'instance-03-ip:9100']
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018893488/80f5c730-4dd3-44aa-a580-0094e0a0d1f7.png align="center")

Then, restart Prometheus to apply changes and Navigate to `http://<instance-01-ip>:9090/targets` to verify all your targets are listed and **UP**.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018943048/6b435615-b6a8-4579-b603-2709a9602332.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746018949479/629cfd3b-6e80-472b-83f6-8d3af98a3912.png align="center")

### Step 5: Set Up Grafana Dashboard

Head over to your Grafana dashboard:

* Click **Connections &gt; Add new connection**
    
* Choose **Prometheus** and set the URL to `http://<instance-01-ip>:9090`
    
* Save and test the connection
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019006071/652316cf-cccc-46ec-a2bf-5f7e488e84fa.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019013890/dbf2da52-8d0b-42d1-92cb-c54d3f7611d8.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019030230/ea3e46d4-b716-427f-93c5-4be6e467e3eb.png align="center")

Now for the fun part—dashboards!

* Go to **Dashboards &gt; Import**
    
* Upload the JSON file provided in the GitHub repo
    
* Click **Load**
    
* Select the Prometheus data source and click **Import**
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019088976/1b43973a-48c8-474a-bcc7-90378f6ad1c7.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019097651/4a336878-2422-44cf-b6b0-9280208780c8.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019108037/c64a93bf-e5a1-43af-b1ed-50ae00d67e2b.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019115574/0d7193cb-b9dc-4c3a-89fb-4a31947058c3.png align="center")

**Boom! Your monitoring dashboard is live.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019171932/cb821a67-d289-467b-af6b-d3f346080b22.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1746019179357/3e6d6959-4d7f-4f15-ad4c-9ef1b0fbadf1.png align="center")

That’s it! In just a few simple steps, you’ve got a monitoring setup with Prometheus and Grafana across multiple instances. This stack is powerful for monitoring or demo purposes.  
Feel free to fork the [GitHub repo](https://github.com/linnlattoo-cloud/prometheus_grafana) and customize your dashboard or explore alerting features next!
