Cortex is a horizontally scalable, multi-tenant long-term storage backend for Prometheus. Prometheus servers remote-write their samples into Cortex, which stores them in object storage (S3, GCS, Azure Blob) and exposes a fully PromQL-compatible query API. Tenants are identified by the X-Scope-OrgID header, so a single Cortex cluster can serve metrics for dozens or hundreds of isolated teams or customers.
Cortex is decomposed into a handful of microservices that you can scale independently: distributors hash and replicate incoming samples to ingesters; ingesters buffer recent data in memory and periodically flush TSDB blocks to object storage; the store-gateway serves historical blocks; queriers fan out PromQL reads across ingesters and store-gateways; the query-frontend splits long queries, caches results, and queues them; the compactor merges and deduplicates blocks in the background. It uses a hash ring (backed by Consul, etcd, or memberlist) for service discovery and sharding.
Historically, Cortex and Thanos were the two main answers to the “global Prometheus” problem. In 2022, Grafana Labs forked Cortex to create Grafana Mimir, and much of the active development shifted there. Cortex itself is still maintained in CNCF incubation, but Mimir, Thanos, and VictoriaMetrics are now the more commonly deployed options for new long-term Prometheus storage.