How to Install Prometheus and Collect Metrics on AWS Amazon Linux 2023

πŸš€ How to Install Prometheus and Collect Metrics on AWS Amazon Linux 2023

TL;DR: Prometheus alone won’t show much data β€” it only monitors itself. To get real server metrics like CPU, RAM, disk, and network, you need to install Node Exporter and configure Prometheus to scrape it. In this post, I’ll walk you through setting up Prometheus + Node Exporter on an EC2 instance running Amazon Linux 2023.

πŸ”Ή Step 1: Install Prometheus on Amazon Linux 2023

Update system:

sudo dnf update -y

Create Prometheus user and directories:

sudo useradd --no-create-home --shell /bin/false prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus

Download the latest Prometheus binary:

cd /tmp
curl -LO https://github.com/prometheus/prometheus/releases/download/v2.55.1/prometheus-2.55.1.linux-amd64.tar.gz
tar xvf prometheus-2.55.1.linux-amd64.tar.gz
cd prometheus-2.55.1.linux-amd64

Move binaries and set permissions:

sudo cp prometheus promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
sudo cp -r consoles/ console_libraries/ /etc/prometheus/

Create a basic configuration:

sudo tee /etc/prometheus/prometheus.yml > /dev/null <<EOF
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
EOF

sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml

Create a systemd service file:

sudo tee /etc/systemd/system/prometheus.service > /dev/null <<EOF
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus/ \
  --web.console.templates=/etc/prometheus/consoles \
  --web.console.libraries=/etc/prometheus/console_libraries

[Install]
WantedBy=multi-user.target
EOF

Start Prometheus:

sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus

Access the UI:

http://<EC2-Public-IP>:9090

πŸ”Ή Step 2: Install Node Exporter (System Metrics)

Node Exporter provides CPU, memory, disk, and network usage.

Download and install:

cd /tmp
curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
tar xvf node_exporter-1.8.2.linux-amd64.tar.gz
sudo cp node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin/

Create a systemd service:

sudo tee /etc/systemd/system/node_exporter.service > /dev/null <<EOF
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=nobody
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=default.target
EOF

Start Node Exporter:

sudo systemctl daemon-reload
sudo systemctl enable node_exporter
sudo systemctl start node_exporter

Verify it’s running:

http://<EC2-Public-IP>:9100/metrics

πŸ”Ή Step 3: Add Node Exporter to Prometheus

Edit Prometheus config:

sudo nano /etc/prometheus/prometheus.yml

Add a new scrape job:

  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']

Restart Prometheus:

sudo systemctl restart prometheus

πŸ”Ή Step 4: Verify Metrics

Go to:

http://<EC2-Public-IP>:9090/targets

You should see:

  • βœ… Prometheus itself
  • βœ… Node Exporter

Run queries like:

  • up (check active targets)
  • node_cpu_seconds_total
  • node_memory_MemAvailable_bytes
  • node_network_receive_bytes_total

πŸ”‘ Why No Data Before?

  • Prometheus only monitors itself by default.
  • Without exporters, you won’t see system metrics.
  • Node Exporter is the standard method for monitoring Linux servers.

πŸ“Š Next Step: Grafana (Optional)

For better visualization, install Grafana and connect it to Prometheus. Grafana provides ready-made dashboards for Node Exporter.

βœ… Final Thoughts

You’ve now installed Prometheus and Node Exporter on Amazon Linux 2023 EC2, and you can finally see system metrics flowing into Prometheus. This setup serves as the foundation for monitoring EC2 instances, Docker containers, or Kubernetes clusters.

Atiqur Rahman

I am MD. Atiqur Rahman graduated from BUET and is an AWS-certified solutions architect. I have successfully achieved 6 certifications from AWS including Cloud Practitioner, Solutions Architect, SysOps Administrator, and Developer Associate. I have more than 8 years of working experience as a DevOps engineer designing complex SAAS applications.

Leave a Reply