Course contentsShow
← System Design
Lesson 1198 of 1,91930. Observability: MetricsFree lesson

Prometheus Architecture and Data Model

Understand Prometheus's time-series database, label-based data model, and how it stores and queries metrics efficiently.

Prometheus Architecture and Data Model

What You'll Learn

You'll learn how Prometheus structures its time-series database, uses labels to organize metrics, and efficiently stores and queries monitoring data.

Core Architecture

Prometheus is a pull-based monitoring system with a built-in time-series database (TSDB). At its core, it periodically scrapes HTTP endpoints (called targets) to collect metrics, stores them locally, and makes them queryable via PromQL.

The key components:

  • Scraper: Pulls metrics from configured endpoints at fixed intervals (e.g., every 15 seconds)
  • TSDB: Stores time-series data efficiently on disk in compressed chunks
  • Query Engine: Executes PromQL queries against stored data
  • Alertmanager (separate component): Handles alert routing and notifications

The Label-Based Data Model

Prometheus doesn't use hierarchical namespaces like traditional databases. Instead, every time-series is uniquely identified by:

  • A metric name (e.g., http_requests_total)
  • A set of key-value labels (e.g., {service="api", method="GET", status="200"})

Think of labels as dimensions on a spreadsheet—they let you slice and dice the same metric across different attributes.

http_requests_total{service="api", method="GET", status="200"} 1234
http_requests_total{service="api", method="POST", status="201"} 567

Each unique combination of metric name and labels creates a separate time-series. Prometheus indexes these efficiently, allowing fast lookups even with millions of series.

Storage Efficiency

Prometheus uses delta-of-delta encoding and compression to minimize disk usage. Data is written in two-hour blocks, then compacted into larger blocks over time. This structure optimizes both write performance and query speed for recent data—exactly what monitoring needs.

Key Takeaway: Prometheus's pull-based architecture, label-driven data model, and purpose-built TSDB make it exceptionally efficient for storing and querying high-cardinality metrics with minimal operational overhead.