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

Time Series Data Model

Understand metrics as time series with unique label sets and how this affects storage and querying.

Time Series Data Model

What You'll Learn

You'll learn how metrics are stored and queried as time series, where each unique combination of labels creates a separate data stream.

The Time Series Concept

A time series is a sequence of data points indexed by time. In metrics systems, every unique combination of a metric name and its labels creates a distinct time series. For example:

http_requests_total{service="api", endpoint="/users", status="200"}
http_requests_total{service="api", endpoint="/users", status="500"}
http_requests_total{service="api", endpoint="/orders", status="200"}

These are three separate time series, even though they share the same metric name. Each records values over time independently.

How This Affects Storage

Each time series consumes storage for:

  • The label set (stored once, often as a hash)
  • The timestamp-value pairs (stored continuously)

High cardinality (many unique label combinations) creates exponentially more time series. If you have 10 services × 100 endpoints × 5 status codes, that's 5,000 time series for one counter metric. Add user IDs or request IDs as labels? Millions of time series—and potential system overload.

How This Affects Querying

Time series databases optimize for querying by time ranges and label filters. When you query:

http_requests_total{service="api", status="500"}

The system locates all matching time series, then aggregates their values across the time window. More time series = more data to scan and aggregate = slower queries.

Think of each time series like a separate spreadsheet column. A few columns are manageable; thousands require careful indexing and filtering strategies.

Key Takeaway:
The time series data model treats each unique metric-label combination as an independent stream of timestamped values, making cardinality management critical for storage efficiency and query performance.