Skip to content

20MH1A04H9/Prometheus

Repository files navigation

🚀 Prometheus Monitoring System

Prometheus Ubuntu Architecture License

A complete guide to installing and configuring Prometheus Monitoring System on Ubuntu Server (amd64).


📌 Table of Contents


📖 Introduction

What is Prometheus?

Prometheus is an open-source monitoring and alerting toolkit originally developed by SoundCloud.

It is widely used for monitoring:

  • Servers
  • Applications
  • Containers
  • Kubernetes
  • Cloud Infrastructure

Prometheus collects metrics from configured targets at regular intervals, stores them as time-series data, and allows users to query them using:

PromQL (Prometheus Query Language)

Prometheus is commonly integrated with:

  • Grafana → Visualization
  • Alertmanager → Alerts & Notifications

✨ Key Features

✅ Time-series metrics storage
✅ Powerful query language (PromQL)
✅ Built-in alerting system
✅ Pull-based metrics collection
✅ Service discovery support
✅ Multi-dimensional data model (labels)
✅ Kubernetes integration
✅ Linux/Windows monitoring support


🏗 Architecture

Prometheus follows a pull-based monitoring architecture.

                +----------------------+
                |     Applications     |
                | (Node Exporter, App) |
                +----------+-----------+
                           |
                           | HTTP Metrics
                           v
                   +---------------+
                   |  Prometheus   |
                   |    Server     |
                   |---------------|
                   | Scraping      |
                   | TSDB Storage  |
                   | Query Engine  |
                   +-------+-------+
                           |
            +--------------+--------------+
            |                             |
            v                             v
    +--------------+             +----------------+
    | Alertmanager |             |    Grafana     |
    | Alert Engine |             | Visualization  |
    +--------------+             +----------------+

⚙️ Prometheus Components

1. Prometheus Server

Core component responsible for:

  • Scraping metrics
  • Storing time-series data
  • Running queries
  • Triggering alerts

2. Exporters

Exporters expose system/application metrics.

Common Exporters:

  • Node Exporter → Linux metrics
  • Windows Exporter → Windows metrics
  • MySQL Exporter
  • Nginx Exporter

Example:

http://<server-ip>:9100/metrics

3. Alertmanager

Handles alerts generated by Prometheus.

Features:

  • Alert deduplication
  • Alert grouping
  • Silence management
  • Notification routing

Supported Notifications:

  • Email
  • Slack
  • PagerDuty
  • Webhooks

4. Grafana

Grafana visualizes Prometheus metrics through dashboards.

Example dashboards:

  • CPU Usage
  • Memory Usage
  • Disk IO
  • Network Traffic

🔄 Data Flow

Exporter → Prometheus → Storage → Query → Grafana Dashboard
                                 ↓
                           Alertmanager

🛠 Installation Guide (Ubuntu Server amd64)

Step 1: Update System

sudo apt update && sudo apt upgrade -y

Step 2: Create Prometheus User

sudo useradd --no-create-home --shell /bin/false prometheus

Step 3: Create Required Directories

sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus

Set permissions:

sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus

Step 4: Download Prometheus

cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v3.9.1/prometheus-3.9.1.linux-amd64.tar.gz

Extract files:

tar xvf prometheus-3.9.1.linux-amd64.tar.gz
cd prometheus-3.9.1.linux-amd64

Step 5: Copy Binaries

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

Set ownership:

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

Step 6: Copy Configuration Files

sudo cp -r consoles /etc/prometheus
sudo cp -r console_libraries /etc/prometheus
sudo cp prometheus.yml /etc/prometheus

Set permissions:

sudo chown -R prometheus:prometheus /etc/prometheus

Step 7: Create Systemd Service

Create service file:

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

Add the following configuration:

[Unit]
Description=Prometheus Monitoring Service
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
WorkingDirectory=/var/lib/prometheus

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

Restart=always
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Step 8: Start Prometheus Service

Reload systemd:

sudo systemctl daemon-reload

Enable service:

sudo systemctl enable prometheus

Start service:

sudo systemctl start prometheus

Check service status:

sudo systemctl status prometheus

🌐 Access Prometheus UI

Open your browser:

http://SERVER-IP:9090

Prometheus dashboard should load successfully.


✅ Verify Metrics

Run the following query in Prometheus UI:

up

Expected result:

up = 1

This means the target is healthy.


🔌 Default Ports

Service Port
Prometheus 9090
Node Exporter 9100
Alertmanager 9093
Grafana 3000

🏢 Recommended Production Architecture

Servers → Node Exporter
            ↓
        Prometheus
            ↓
       Alertmanager
            ↓
          Grafana

🎯 Use Cases

Prometheus is commonly used for:

  • Infrastructure Monitoring
  • Kubernetes Monitoring
  • Application Performance Monitoring
  • DevOps Observability
  • SRE Monitoring
  • Security Monitoring Integration

✅ Summary

Prometheus is a powerful open-source monitoring solution built for:

  • Reliability
  • Scalability
  • Real-time monitoring
  • Alerting
  • Observability

When combined with Grafana and Alertmanager, it becomes a complete monitoring stack for modern infrastructure.


🤝 Contributing

Feel free to fork this repository and submit pull requests.


📜 License

This project is licensed under the MIT License.

About

Open source metrics and monitoring for your systems and services

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors