Prometheus Server Configuration on AWS EC2 Machine

Prometheus Server Setup:

Step 1: Update the yum package repositories.

sudo yum update -y

Step 2: Create a Prometheus user, and required directories, and make the Prometheus user as the owner of those 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

sudo chown prometheus:prometheus /var/lib/prometheus

Step 3: Go to the official Prometheus downloads page (https://prometheus.io/)and get the download link for the Linux binary.

https://github.com/prometheus/prometheus/releases/download/v2.36.1/prometheus-2.36.1.linux-amd64.tar.gz

Step 4: Download the source using wget, unzip the package then rename the extracted folder to prometheus-files.

wget https://github.com/prometheus/prometheus/releases/download/v2.36.1/prometheus-2.36.1.linux-amd64.tar.gz

tar -xvf tar_pkg_name

mv prometheus-2.17.3.linux-amd64 prometheus-files

Step 5: Copy Prometheus and promtool binary from prometheus-files folder to /usr/local/bin and change the ownership to prometheus user.

sudo cp prometheus-files/prometheus /usr/local/bin/

sudo cp prometheus-files/promtool /usr/local/bin/

sudo chown prometheus:prometheus /usr/local/bin/prometheus

sudo chown prometheus:prometheus /usr/local/bin/promtool

Step 6: Move the consoles and console_libraries directories from prometheus-files to /etc/prometheus folder and change the ownership to Prometheus user.

sudo cp -r prometheus-files/consoles /etc/prometheus

sudo cp -r prometheus-files/console_libraries /etc/prometheus

sudo chown -R prometheus:prometheus /etc/prometheus/consoles

sudo chown -R prometheus:prometheus /etc/prometheus/console_libraries

Setup Prometheus Configuration:

All the Prometheus configurations should be present in /etc/prometheus/prometheus.yml file.

Step 1: Create the prometheus.yml file.

sudo vi /etc/prometheus/prometheus.yml

Step 2: Copy the following contents to the prometheus.yml file.

global:

  scrape_interval: 10s

scrape_configs:

  - job_name: 'prometheus'

    scrape_interval: 10s

    static_configs:

      - targets: ['server_ip:9090']

Step 3: Change the ownership of the file to the Prometheus user.

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

Setup Prometheus Service File:

Step 1: Create a Prometheus service file.

sudo vi /etc/systemd/system/prometheus.service

Step 2: Copy the following content to the file.

[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

Step 3: Reload the systemd service to register the Prometheus service and start the Prometheus service.

sudo systemctl daemon-reload

sudo service prometheus start

service prometheus status

sudo systemctl enable prometheus

sudo systemctl status prometheus

Step 4: Access Prometheus Web UI

http//:ec2serverip:9090

Learn about What is Prometheus? and How does it work?

Prometheus Architecture?


Prometheus Server Configuration

---

Thanks & Regards,

Kanchan Soni (https://linktr.ee/kanchansoni)

(A girl who saw the dream with an open eye to compete with self capability in the area of IT and its Next-Gen Technology, with the ability to complete the task with perfection.)

Email: kanchansoni.cse@gmail.com



Comments

People also Look For

All about DevOps (A Complete Guide to DevOps)

How to Implement Microservice Coded In Hackathon Event

Upcoming DevOps trends

All about Cloud Computing