Prometheus – Open Source Monitoring and Alerting Toolkit
What is Prometheus?
Prometheus is an open-source systems monitoring and alerting toolkit originally built at SoundCloud in 2012. Since its inception, it has become one of the most widely adopted monitoring solutions, joining the Cloud Native Computing Foundation (CNCF) in 2016 as the second hosted project after Kubernetes.
📑 Table of Contents
Designed for reliability and scalability, Prometheus excels at recording real-time metrics in a time series database built using an HTTP pull model, with flexible queries and real-time alerting capabilities.
Key Features
- Multi-dimensional data model: Time series identified by metric name and key/value pairs for flexible querying
- PromQL query language: Powerful and expressive query language to slice and dice collected data
- No distributed storage dependency: Single server nodes are autonomous and reliable
- Pull-based architecture: Scrapes metrics over HTTP from configured targets
- Push gateway support: For short-lived jobs that cannot be scraped
- Service discovery: Automatic target discovery via Kubernetes, Consul, EC2, and more
- Built-in alerting: Define alert rules and send notifications via Alertmanager
- Graphing and dashboarding: Multiple visualization modes including built-in expression browser
Architecture Overview
The Prometheus ecosystem consists of several components:
- Prometheus server: Scrapes and stores time series data
- Client libraries: Instrument application code for various languages
- Push gateway: Support for short-lived jobs
- Exporters: Export metrics from third-party systems
- Alertmanager: Handle alerts sent by Prometheus server
System Requirements
- 64-bit Linux, macOS, or Windows
- Minimum 2 CPU cores recommended
- At least 4GB RAM for small deployments
- SSD storage recommended for better performance
- Storage: approximately 1-2 bytes per sample
Installation Guide
docker">Using Docker
docker run -d \
--name prometheus \
-p 9090:9090 \
-v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
Binary Installation
# Download the latest release
wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz
# Extract the archive
tar xvfz prometheus-*.tar.gz
cd prometheus-*
# Run Prometheus
./prometheus --config.file=prometheus.yml
Systemd Service Setup
# Create prometheus user
sudo useradd --no-create-home --shell /bin/false prometheus
# Create directories
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
# Create systemd service file
sudo cat > /etc/systemd/system/prometheus.service << 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/
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
Configuration Example
# prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
- alertmanager:9093
rule_files:
- "alert_rules.yml"
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "node"
static_configs:
- targets: ["localhost:9100"]
PromQL Query Examples
CPU Usage
100 - (avg by(instance) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
Memory Usage
(1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100
Disk Usage
(1 - (node_filesystem_avail_bytes / node_filesystem_size_bytes)) * 100
Integration with Grafana
Prometheus works seamlessly with Grafana for advanced visualization. Add Prometheus as a data source in Grafana and leverage thousands of community-built dashboards for comprehensive monitoring.
Use Cases
- Infrastructure monitoring (servers, containers, VMs)
- Application performance monitoring
- Kubernetes cluster monitoring
- Microservices observability
- Alerting and incident response
Download
Prometheus is released under the Apache 2.0 license. Download the latest version:
Latest Version: 2.48.0
License: Apache 2.0
Maintained by: Cloud Native Computing Foundation
Was this article helpful?
About Ramesh Sundararamaiah
Red Hat Certified Architect
Expert in Linux system administration, DevOps automation, and cloud infrastructure. Specializing in Red Hat Enterprise Linux, CentOS, Ubuntu, Docker, Ansible, and enterprise IT solutions.