RousselTMLEARNING

Observability

Mimir: multi-tenancy, limits and runtime configuration

Isolate teams in Mimir: tenants and the X-Scope-OrgID header, gateway authentication, ingestion and query limits, hot per-tenant overrides and shuffle sharding.

1. Tenants #

Complete logical isolation.

Principle #

In Mimir, every request carries a tenant identifier in the X-Scope-OrgID header. Data, rules, Alertmanager and limits are separated per tenant: a team never sees another team's series.

multitenancy_enabled: true   # défaut
Common mistake: Mimir does not authenticate: it trusts the header. In production, put a gateway in front of it (nginx, Envoy, Grafana Enterprise Metrics) that authenticates the client and then injects the right X-Scope-OrgID.

Example nginx gateway #

map $remote_user $tenant {
  equipe-web      web;
  equipe-data     data;
}
server {
  listen 80;
  auth_basic           "Mimir";
  auth_basic_user_file /etc/nginx/htpasswd;
  location / {
    proxy_set_header X-Scope-OrgID $tenant;
    proxy_pass http://mimir:8080;
  }
}

Multi-tenant queries #

With tenant_federation.enabled: true, a query can target several tenants: X-Scope-OrgID: web|data. The __tenant_id__ label then shows the origin of each series. Handy for a central SRE team.

2. Limits #

Protecting the cluster from abuse and mistakes.

Ingestion limits #

LimitDefaultMeaning
ingestion_rate10,000Samples/s per tenant
ingestion_burst_size200,000Tolerated burst
max_global_series_per_user150,000Active series per tenant (across the whole cluster)
max_global_series_per_metric0 (unlimited)Active series per metric name
max_label_names_per_series30Number of labels per series
max_label_value_length2048Length of a label value
out_of_order_time_window0Window for accepting late samples

Exceeding a limit results in 429 or 400 errors on the Prometheus side and in the cortex_discarded_samples_total{reason=...} metric on the Mimir side.

Common mistake: The default values are deliberately low. The first « bug » encountered in production is almost always per_user_series_limit: raise the limits of the tenant concerned rather than disabling the check.

3. Runtime configuration #

Changing limits without restarting.

runtime.yaml #

# mimir.yaml
runtime_config:
  file: /etc/mimir/runtime.yaml
  period: 10s
# runtime.yaml (relu toutes les 10 s)
overrides:
  web:
    ingestion_rate: 50000
    ingestion_burst_size: 1000000
    max_global_series_per_user: 2000000
  data:
    max_global_series_per_user: 500000
    max_fetched_series_per_query: 100000
    ingestion_tenant_shard_size: 6   # shuffle sharding : 6 ingesters seulement

The /runtime_config page shows the overrides in effect; /runtime_config?mode=diff shows what differs from the default values.

Shuffle sharding #

Without shuffle sharding, every tenant uses all ingesters and all queriers: a tenant sending a monstrous query slows everyone down. By assigning each tenant a random subset of instances (ingestion_tenant_shard_size, max_queriers_per_tenant, store_gateway_tenant_shard_size), the blast radius of a noisy tenant is limited.

Good practice: Start by measuring: cortex_ingester_active_series per tenant and the /ingester/tenants page show who consumes what.

Related articles

The LGTM stack (Loki, Grafana, Tempo, Mimir): architecture and setup

Grafana Labs' LGTM stack: Loki for logs, Grafana for visualization, Tempo for traces, Mimir for metrics (and …

Why Grafana Mimir? Architecture and deployment modes

The limits of Prometheus alone, what Mimir brings (long-term storage, high availability, multi-tenancy), its …

Mimir: the write path (distributor, ingesters, replication and HA deduplication)

How Mimir ingests metrics: remote_write, distributor validation and limits, hash ring, ingester replication, …

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!