ScriptsApr 16, 2026·3 min read

Cortex — Horizontally Scalable Long-Term Storage for Prometheus

Cortex is a CNCF project that provides horizontally scalable, highly available, multi-tenant, long-term storage for Prometheus metrics, letting you run Prometheus-as-a-Service at scale.

TL;DR
Cortex provides horizontally scalable, highly available, multi-tenant long-term storage for Prometheus metrics at any scale.
§01

What it is

Cortex is a CNCF incubating project that extends Prometheus with horizontally scalable, highly available, multi-tenant long-term storage. It accepts Prometheus metrics via remote write, stores them durably, and serves PromQL queries across months or years of data. Cortex lets organizations run Prometheus-as-a-Service without losing data when individual Prometheus instances restart.

It targets platform teams and SRE organizations that run Prometheus at scale and need durable metric storage, multi-tenancy for different teams, and query federation across multiple Prometheus instances.

§02

How it saves time or tokens

Standalone Prometheus stores metrics locally and loses data on restart or disk failure. Cortex adds durable storage with object store backends (S3, GCS, Azure Blob), so metric history persists indefinitely. Multi-tenancy means one Cortex cluster serves multiple teams without running separate Prometheus stacks for each. Horizontal scaling handles growing ingestion rates without re-architecting.

§03

How to use

  1. Deploy Cortex components (distributor, ingester, querier, compactor) using Helm charts or Docker Compose.
  2. Configure your existing Prometheus instances to remote-write to Cortex's distributor endpoint.
  3. Point Grafana or other visualization tools at Cortex's query endpoint for long-term metric queries.
§04

Example

# prometheus.yml - configure remote write to Cortex
remote_write:
  - url: http://cortex-distributor:9009/api/v1/push
    headers:
      X-Scope-OrgID: team-backend

# Query long-term metrics via Cortex
# Grafana datasource: http://cortex-querier:9009/prometheus
§05

Related on TokRepo

§06

Common pitfalls

  • Cortex has many microservice components. Start with single-binary mode for testing, then decompose into microservices for production scaling.
  • Object storage costs accumulate with long retention periods. Configure compaction and downsampling to manage storage costs for multi-year retention.
  • Multi-tenancy requires setting the X-Scope-OrgID header on all requests. Missing headers cause authentication errors or data routing to a default tenant.

Frequently Asked Questions

How does Cortex differ from Thanos?+

Both add long-term storage and high availability to Prometheus. Cortex ingests metrics via remote write and stores them centrally. Thanos uses a sidecar model that reads from existing Prometheus instances and uploads to object storage. Cortex is better for centralized Prometheus-as-a-Service; Thanos is better for federated existing Prometheus deployments.

What storage backends does Cortex support?+

Cortex supports Amazon S3, Google Cloud Storage, Azure Blob Storage, and any S3-compatible object store (like MinIO) for long-term block storage. It uses a key-value store (DynamoDB, Consul, etcd, or memberlist) for hash ring coordination.

Is Cortex production-ready?+

Yes. Cortex is a CNCF incubating project used in production by multiple organizations. It also forms the basis of commercial offerings like Grafana Cloud's metrics backend.

How does multi-tenancy work?+

Each request includes an X-Scope-OrgID header identifying the tenant. Cortex isolates data and queries per tenant. Rate limits, retention policies, and access controls can be configured per tenant. This enables a single cluster to serve multiple independent teams.

Can I migrate from standalone Prometheus to Cortex?+

Yes. Add a remote_write configuration to your existing Prometheus instances pointing at Cortex. Prometheus continues scraping targets as before; Cortex stores the data for long-term retention and cross-instance queries. The migration is additive, not disruptive.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets