PROMETHEUS
METRICS

// The metrics database for cloud-native.

PROMETHEUS CHANGED HOW WE THINK ABOUT METRICS.

Originally built at SoundCloud, Prometheus is now a CNCF graduated project. It pulls metrics from targets, stores them efficiently, and lets you query with PromQL—a powerful expression language for time series data.

WHY PROMETHEUS?

Prometheus uses a pull model—it scrapes metrics from targets over HTTP. No agents needed on most systems. It handles millions of time series, alerts on conditions, and integrates perfectly with Grafana for visualization.

JOIN THE METRICS REVOLUTION.

Learn to instrument your applications, write PromQL queries, set up alerting rules, and build dashboards. Prometheus is the backbone of modern observability.

BEGIN YOUR JOURNEY →

// The Path to Prometheus Mastery

10 lessons. Complete metrics control.

LESSON 01

Introduction to Prometheus

What is Prometheus and how it works

Beginner
LESSON 02

Installation & Setup

Install Prometheus and configure

Beginner
LESSON 03

Metrics & Labels

Understanding metrics and label dimensions

Beginner
LESSON 04

PromQL Basics

Query Prometheus with PromQL

Beginner
LESSON 05

Exporters

Node, cAdvisor, and custom exporters

Intermediate
LESSON 06

PromQL Advanced

Functions, aggregations, and joins

Intermediate
LESSON 07

Recording Rules

Pre-compute complex queries

Intermediate
LESSON 08

Alerting

Define and route alerts with Alertmanager

Intermediate
LESSON 09

Service Discovery

Auto-discover targets in Kubernetes

Advanced
LESSON 10

Grafana Integration

Build dashboards with Grafana

Advanced

// Why Prometheus

Prometheus was created by Matt Levachimov and Julius Volz at SoundCloud in 2012. It joined CNCF in 2016 and graduated in 2018—the second project to do so after Kubernetes.

Unlike traditional monitoring systems with push agents, Prometheus uses a pull model. It scrapes metrics from HTTP endpoints at regular intervals. This makes it simple, reliable, and scalable to thousands of targets.

Prometheus stores time series data with dimensional data—each metric has labels (key-value pairs) that allow flexible querying. This multidimensional approach, combined with PromQL, makes Prometheus incredibly powerful.

Metrics are truth. Let Prometheus show you the truth.

// Tools & References

📖 Prometheus Docs

Official Documentation

prometheus.io/docs

📊 Grafana

Visualization

grafana.com

📦 Exporters

Metrics Exporters

exporters

🖥️ Node Exporter

System Metrics

node_exporter

🧊 cAdvisor

Container Metrics

cadvisor

🔔 Alertmanager

Alert Routing

alertmanager

// Introduction to Prometheus

×

What is Prometheus?

Prometheus is an open-source systems monitoring and alerting toolkit. It collects and stores metrics as time series data—numerical values identified by metric name and optional key-value labels.

Key Concepts

  • Metrics: Numerical measurements over time
  • Targets: Services or systems being monitored
  • Exporters: Programs that expose metrics in Prometheus format
  • Scrape: Prometheus pulls metrics from targets
  • PromQL: Prometheus Query Language
PROMETHEUS PHILOSOPHY: "Pull over push." Prometheus scrapes metrics from targets, rather than waiting for them to push data. This makes it simpler and more reliable.

How Prometheus Works

# # Prometheus server: # # 1. Scrapes metrics from targets at regular intervals # # 2. Stores time series data locally # # 3. Evaluates alerting rules # # 4. Exposes API for querying

Quiz

1. Prometheus uses a _____ model.

Hint: Opposite of push

2. Programs exposing metrics are called _____.

Hint: Export metrics

3. Metrics stored as _____ series.

Hint: Time-based

4. Query language is _____.

Hint: Prometheus Query Language

5. Prometheus collects from targets at regular _____.

Hint: Regular times

Show Answers

Answers

1. Pull

2. Exporters

3. Time

4. PromQL

5. Intervals

// Installation & Setup

×

Installing Prometheus

Prometheus can run as a binary, in Docker, or on Kubernetes. The binary is simplest for learning.

Quick Start

$ curl -LO https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz $ tar xzf prometheus-*.linux-amd64.tar.gz $ cd prometheus-2.47.0.linux-amd64 $ ./prometheus --config.file=prometheus.yml

Basic Configuration

# prometheus.yml global: scrape_interval: 15s evaluation_interval: 15s alerting: alertmanagers: - static_configs: - targets: - alertmanager:9093 rule_files: - "rules/*.yml" scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090']

Quiz

1. Default scrape interval is _____ seconds.

Hint: 15

2. Configuration file is prometheus._____.

Hint: YAML

3. Alert rules in _____ files.

Hint: Rules

Show Answers

Answers

1. 15

2. yml

3. Rule

// Metrics & Labels

×

Metric Format

Prometheus metrics follow a specific format with metric name and labels.

Metric Structure

# metric_name{label1="value1", label2="value2"} # Example: # process_cpu_seconds_total{job="prometheus", instance="localhost:9090"} # # - metric name: process_cpu_seconds_total # - labels: job, instance # - value: number (seconds)

Metric Types

  • Counter: Always increasing (requests_total, errors_total)
  • Gauge: Can go up or down (memory_usage, temperature)
  • Histogram: Buckets for distributions (request_duration)
  • Summary: Quantiles over sliding window (response_latency)

Quiz

1. A metric that only increases is a _____.

Hint: Counting

2. A metric that goes up and down is a _____.

Hint: Measurement

3. Key-value pairs attached to metrics are _____.

Hint: Dimensions

4. Histogram is for _____ distributions.

Hint: Bucketed

Show Answers

Answers

1. Counter

2. Gauge

3. Labels

4. Bucket

// PromQL Basics

×

PromQL Overview

PromQL (Prometheus Query Language) lets you select and aggregate time series data.

Basic Queries

# Simple metric query up # Returns 1 if target is up, 0 if down # Query with labels up{job="prometheus"} # Only prometheus job # Range vectors (last 5 minutes) up[5m]

Operators

# Arithmetic rate(http_requests_total[5m]) # rate of requests # Comparison node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 # Memory usage percentage # Logical up == 1 # Only targets that are up

Quiz

1. up{job="prometheus"} filters by _____.

Hint: Label filter

2. up[5m] is a _____ vector.

Hint: Time range

3. Rate calculates per-second _____.

Hint: Speed

Show Answers

Answers

1. Label

2. Range

3. Rate

// Exporters

×

What are Exporters?

Exporters are programs that collect metrics from systems and expose them in Prometheus format. They translate existing monitoring data into Prometheus metrics.

Popular Exporters

  • node_exporter: System metrics (CPU, memory, disk, network)
  • cAdvisor: Docker/container metrics
  • blackbox_exporter: HTTP, TCP, DNS checks
  • mysqld_exporter: MySQL/MariaDB metrics
  • postgres_exporter: PostgreSQL metrics
  • redis_exporter: Redis metrics

Using Node Exporter

$ # Install node_exporter $ ./node_exporter # Listening on :9100 # # Metrics available at: # curl localhost:9100/metrics

Add to Prometheus

scrape_configs: - job_name: 'node' static_configs: - targets: ['localhost:9100']

Quiz

1. _____ exporter collects system metrics.

Hint: System

2. cAdvisor collects _____ metrics.

Hint: Docker

3. Node exporter listens on port _____.

Hint: 9100

Show Answers

Answers

1. Node

2. Container

3. 9100

// PromQL Advanced

×

Aggregation Operators

PromQL provides powerful aggregation to combine metrics across dimensions.

Aggregations

# Sum of all HTTP requests sum(http_requests_total) # Average by job avg by (job) (http_request_duration_seconds) # Count of targets up count(up == 1) # Max CPU usage per instance max by (instance) (rate(cpu_usage[5m]))

Functions

# Rate (per-second) rate(http_requests_total[5m]) # Increase (total growth) increase(http_requests_total[1h]) # Predict future (30 minutes) predict_linear(node_memory_MemAvailable_bytes[10m], 30*60)

Quiz

1. _____ aggregates to total sum.

Hint: Total

2. Predict linear _____ future values.

Hint: Linear

3. Increase shows total _____ over time.

Hint: Change

Show Answers

Answers

1. Sum

2. Linear

3. Growth

// Recording Rules

×

What are Recording Rules?

Recording rules pre-compute expensive queries and store results as new time series. This speeds up dashboards and reduces load.

Rule File

groups: - name: example rules: - record: job:http_requests_total:rate5m expr: rate(http_requests_total[5m]) - record: instance:cpu_usage:avg expr: avg by (instance) (rate(cpu_usage[5m]))

Using Recording Rules

# # Add to prometheus.yml: rule_files: - "rules/*.yml" $ # Reload Prometheus $ curl -X POST http://localhost:9090/-/reload

Quiz

1. Recording rules pre-_____ expensive queries.

Hint: Calculate

2. Rules stored in _____ files.

Hint: YAML

3. Reload API endpoint is /-/_____.

Hint: Reload

Show Answers

Answers

1. Compute

2. yml

3. Reload

// Alerting

×

Alert Rules

Prometheus evaluates alert rules and sends to Alertmanager when conditions are met.

Alert Rule Example

groups: - name: example_alerts rules: - alert: HighMemoryUsage expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.1 for: 5m labels: severity: warning annotations: summary: "High memory usage detected" description: "Memory usage is above 90%"

Alertmanager Config

global: resolve_timeout: 5m route: receiver: 'email' receivers: - name: 'email' email_configs: - to: 'alerts@example.com'

Quiz

1. Alert rules evaluate and send to _____.

Hint: Alert manager

2. Duration before firing with _____ clause.

Hint: Wait period

3. Annotations provide _____ details.

Hint: What happened

Show Answers

Answers

1. Alertmanager

2. For

3. Description

// Service Discovery

×

Dynamic Target Discovery

Instead of static configs, use service discovery to automatically find targets in Kubernetes, Docker, EC2, and more.

Kubernetes SD

scrape_configs: - job_name: 'kubernetes-pods' kubernetes_sd_configs: - role: pod relabel_configs: - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] action: keep regex: true

Relabeling

# Relabeling transforms labels during scraping # __meta_* contain service discovery metadata # Use regex to filter and transform

Quiz

1. _____ discovery auto-finds targets.

Hint: Auto-find

2. K8s SD uses role _____.

Hint: Pod

3. _____ configs transform labels.

Hint: Label modification

Show Answers

Answers

1. Service

2. Pod

3. Relabel

// Grafana Integration

×

Prometheus + Grafana

Grafana is the standard visualization tool for Prometheus. Add Prometheus as a data source and build dashboards.

Add Data Source

# In Grafana: # 1. Configuration → Data Sources # 2. Add Prometheus # 3. URL: http://localhost:9090 # 4. Save & Test

Query in Grafana

# In dashboard panels: rate(http_requests_total{job="$job"}[5m]) # Variables: $__rate_interval # Auto-adjusts for scrape interval

Dashboards

Import pre-built dashboards from Grafana.com. Search for "Prometheus" to find community dashboards for Kubernetes, nodes, databases, and more.

Quiz

1. Grafana visualizes _____ from Prometheus.

Hint: Data

2. Import dashboards from _____.com.

Hint: Grafana

3. Auto-interval variable is $__rate _____.

Hint: Interval

Show Answers

Answers

1. Metrics

2. Grafana

3. Interval