Multi-tenant Loki for SaaS: what it does and when you need it
A SaaS company or managed service provider that wants one log store for many customers needs Loki to keep each customer's logs apart. Loki does this with tenant isolation driven by the X-Scope-OrgID header, but only when auth_enabled is set to true. With that setting on, every read and write request must carry a tenant ID, and Loki stores and queries each tenant's data under that ID. With it off, Loki runs as a single tenant and the header is ignored, so this is the first setting to verify in any multi-customer design.
Loki has no built-in authentication. Customers do not send X-Scope-OrgID themselves, and the Loki documentation says an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium must sit in front of it. That proxy checks each customer's credential, maps it to the correct tenant ID and sets the header before forwarding. The mapping table, its ownership and its failure behavior become part of your security boundary, so they belong in your threat model and your access review. Confirm how each candidate proxy handles header injection and stripping before you rely on it.
Retention and limits are also set per tenant. Loki's compactor applies retention, which is disabled by default, and can be configured globally, per tenant or per stream selector. Ingestion and query limits can differ between tenants through runtime overrides. This is what lets a large customer and a small one share a cluster under different terms. Decide early whether you need this model at all: if your tenants are internal teams that trust each other, a single tenant with label selectors may be simpler, and if customers need contractual deletion or separate audit trails, the per-tenant design is the one to plan around.
How a customer query reaches its own tenant
The request starts at the customer's client or Grafana and goes to an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium. That proxy checks the customer's credential, strips any tenant header the client sent, and sets X-Scope-OrgID from its own mapping. Loki trusts only that header and reads or writes chunks and index entries in object storage under the tenant. Check that Loki is not reachable directly from customer networks, because the proxy is the only thing enforcing tenant identity.
Proxy sets the tenant header before Loki sees the request.
Which multi-tenant design fits which situation
This table compares three ways to map customers, environments or products onto Loki tenants. Read each row for when the design fits, what it costs to operate and what the isolation actually depends on. The main takeaway is that open-source Loki isolates data by tenant ID, so label-based separation inside one tenant needs Grafana Enterprise Logs features that you should confirm for your planned version.
| Design | When it fits | Operational cost | Isolation depends on |
|---|---|---|---|
| One tenant per customer | Customers need hard data separation, per-customer retention or per-customer limits, and the number of customers is moderate. | Tenant limits, retention rules and overrides must be managed per customer, and the proxy must map every credential to the right tenant ID. | The authenticating proxy setting X-Scope-OrgID correctly on every request, plus per-tenant limits. |
| One tenant per environment or product | Your own teams run several products or stages (production, staging) and customer data is not split by tenant. | Few tenants to manage, but customer-level separation is not provided, so access to a whole tenant is all-or-nothing. | Access control at the proxy for each tenant, since anyone with tenant access reads all its streams. |
| Shared tenant with label-based separation | Many customers share one tenant and you need each to see only their own streams, for example with a label such as customer. | Requires Grafana Enterprise Logs features for label-based access control and policy headers. Open-source Loki has no built-in equivalent, so confirm the version and edition you plan to run. | Label selectors enforced by the enterprise access layer and the reverse proxy headers that carry the policy, not Loki alone. |
| Illustrative: a managed service provider with 200 small customers | Customers buy the same service and do not need individual retention, so you split by tenant only where contracts demand it. | Per-customer tenants multiply configuration. Ask a partner to estimate tenant administration effort against your onboarding volume. | Proxy mapping and per-tenant limits, reviewed against each customer contract. |
How per-tenant retention, limits and shuffle sharding isolate customers
In a multi-tenant Loki cluster, retention and limits are what keep one customer from shaping the experience of every other customer. Retention is applied by the compactor, and it is disabled by default, so logs are kept indefinitely until retention_enabled is set. Once it is enabled, retention can be defined globally, per tenant or per stream selector. Each stream rule must cover at least 24 hours. For a provider, the practical step is to write down the retention each customer contracted for, map it to a tenant-level rule, and confirm that the compactor runs with retention enabled in the environment you actually operate. A retention rule that exists only in a values file someone meant to apply is a common gap, so verify it against the running configuration and against stored data ages in each tenant.
Per-tenant limits are the main control for protecting neighbors from a noisy customer. Limits such as ingestion rate, stream count and query constraints can be set in the defaults and overridden per tenant through the runtime overrides file, which Loki reloads without a restart. A reasonable plan is to size limits from each customer's agreed volume with headroom, set a conservative default for unknown or new tenants, and expose the effective values with the overrides exporter so that support staff can see what a customer is actually allowed. The exact limit keys, their names, units and how each one behaves under load must be confirmed against the current configuration reference for your Loki version before you publish any limit as a customer commitment.
Shuffle sharding reduces the blast radius of one tenant. Instead of spreading every tenant across all ingesters or queriers, Loki can assign each tenant a subset of the pool, so a tenant that overloads its shard affects fewer other tenants. Decide the shard size with your team before onboarding customers, because it shapes how many tenants share fate, and test that a heavy tenant on a test cluster does not degrade the shards of unrelated tenants. Confirm the shuffle sharding settings and their defaults in the configuration reference, and record which tenants share a shard so that an incident review can answer the question customers will ask first: who else was affected.
How to set up multi-tenant Loki behind an authenticating proxy
This sequence turns a single Loki cluster into a shared service where each customer's logs live in their own tenant, reachable only with that customer's credentials. It produces a tested mapping from authentication to tenant, with retention and limits set per tenant.
Enable multi-tenancy in Loki
Set
auth_enabledto true in the Loki configuration on every component that serves reads or writes, then restart the cluster. Loki is multi-tenant only when this flag is on, and from then on every request must identify a tenant with the X-Scope-OrgID header. Confirm the change by sending a push request without the header, which should be rejected, and another with a test tenant ID, which should be accepted. Check the configuration on all replicas, since a single component left with the old setting can accept unlabeled traffic.Define the tenant ID scheme
Agree in writing who owns tenant ID creation, the naming pattern (for example a stable customer slug or internal account ID), the allowed character set and the maximum length. Tenant IDs are the basis for storage separation, so changing one later requires a data migration, and the scheme should avoid names that customers can change. Reserve a small set of IDs for internal use, such as an operations tenant. Confirm the scheme by creating two tenants from the naming rule and checking that each one's data is written under its own ID.
Place an authenticating proxy in front of Loki
Loki has no built-in authentication layer, so deploy a reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it. The proxy validates each customer credential, looks up the customer's tenant ID and sets X-Scope-OrgID on the forwarded request, removing any value the client supplied. Keep Loki reachable only from the proxy network. Confirm the mapping by sending a request with a valid credential for customer A and inspecting Loki's received tenant header, which must be customer A's ID.
Map each customer credential to one tenant
Maintain a single mapping table from customer identity (API key, token subject or OIDC group) to exactly one tenant ID, owned by the team that onboards customers. Do not let one credential map to several tenants, and do not accept a tenant header from the client. Store the mapping in the system that issues credentials so onboarding and offboarding stay in one place. Confirm each mapping with a test request per customer, and record the results so that the next review can compare them.
Set per-tenant retention and limits
Enable the compactor with retention turned on, since retention is disabled by default and logs are otherwise kept indefinitely. Then set retention globally or per tenant through the runtime overrides file, using the retention period your contracts and policies require. Set ingestion rate, stream count and query limits for each tenant so that one customer cannot consume shared capacity. Confirm the settings by reading the effective limits for each tenant and checking that the compactor reports the retention it applies.
Configure Grafana data sources per tenant
Create one Loki data source in Grafana for each tenant or customer group, and set the
X-Scope-OrgIDcustom HTTP header on it to that tenant's ID. Route each data source through the proxy so the credential, not the header, decides access. Limit Grafana folder and team permissions so customer users only see their own data sources. Confirm the setup by logging in as a customer user and running a query that returns only that customer's streams.Verify isolation with cross-tenant tests
Query each tenant using another tenant's credentials and confirm that no streams, label values or log lines from the owning tenant appear in the results. Repeat the test for label queries, series queries and the Grafana Explore view, since each path goes through the same header logic. Record the test date, the credentials used and the outcome, and rerun the tests after any proxy, Loki or Grafana change. Isolation is confirmed only when every cross-tenant attempt returns no foreign data or is rejected.
Security risks in a shared Loki cluster
A shared Loki cluster puts many customers behind one set of components, so a single mistake in routing, mapping or configuration can expose another customer's logs. The cards below cover the risks we see most often in multi-tenant designs, with generic controls to verify in your own environment.
Forged or stripped tenant headers
Loki is multi-tenant when auth_enabled is true and reads the tenant from the X-Scope-OrgID header on every request. If any client can reach Loki directly, it can set that header to another customer's ID. Confirm that Loki's listener is reachable only from the authenticating proxy, that the proxy overwrites any tenant header a client sends, and that direct access paths such as service mesh routes or port forwards are closed.
Loki multi-tenancy docsCredential mapping errors
Loki has no authentication layer of its own, so the proxy must map each customer credential to exactly one tenant ID. A stale token, a copied client secret or a wildcard rule can send one customer's requests to another customer's tenant. Test the mapping with pairs of accounts from different customers, review how tokens are issued and revoked, and log every mapping decision so a wrong mapping can be traced.
Loki authentication docsShared internal endpoints and admin APIs
Components such as the ingester, query frontend, compactor and ruler expose HTTP endpoints, and some expose administrative functions. These endpoints are shared by every tenant, so a reachable admin path affects all customers at once. Restrict them to the internal network, require authentication for operator access, and confirm which endpoints your deployment mode exposes before go-live.
Customer secrets and personal data in logs
Logs from a customer's application often carry tokens, passwords, card numbers or personal data that the customer never meant to share with you. Once ingested, that content is searchable by anyone with query access to the tenant and persists until retention removes it. Agree with each customer which fields must be dropped or masked before ingestion, and verify the filters in your collection pipeline with sample data.
Retention that differs from contract terms
Retention is disabled by default, so logs are kept indefinitely until retention_enabled is set, and retention can be set globally, per tenant or per stream selector. A single global setting can therefore keep one customer's data longer or shorter than its contract allows. Write each tenant's retention into its configuration, confirm the compactor applies it, and check that deletion requests from customers are reflected in the platform.
Loki retention docsAudit logging of tenant access
Customers in a managed service often ask who queried their logs, when and from where. Loki records what it ingests and serves, but access decisions made by the proxy and by operators need their own audit trail. Decide which events the proxy and administrative tools must log, send those records to storage the operator cannot alter, and confirm with each customer how long those records must be kept.
Where Grafana Enterprise Logs adds features
Open-source Loki gives you multi-tenancy through the auth_enabled setting and the X-Scope-OrgID header, but it has no built-in authentication layer. The Loki documentation says you must run an authenticating reverse proxy in front of it, such as nginx, HAProxy, OAuth2 Proxy or Pomerium. In a SaaS or managed service model, that proxy is the component that turns a customer credential into a tenant identity, so the design decision sits with your team. Your build covers the mapping logic, the header injection and the failure behavior when credentials are missing or invalid.
- Credential mapping: The proxy must map each customer API key, token or SSO identity to exactly one tenant ID and reject anything it cannot map.
- Header control: Clients must never be able to set
X-Scope-OrgIDthemselves, so the proxy should overwrite or strip any value a caller sends. - Tenant isolation testing: You own the tests that prove customer A cannot read customer B's streams through any query path, including Grafana data source settings.
- Operational ownership: Key rotation, proxy upgrades, logging of authentication events and incident response for the proxy all fall to your team.
- Limits of the model: Open-source Loki does not give you label-based restrictions within a tenant or cross-tenant query for operators as built-in features.
Before relying on this path, confirm with your architects who will maintain the proxy and how its audit records will be retained.
Grafana Enterprise Logs (GEL) is Grafana Labs' commercial product based on Loki. According to the GEL documentation, it adds token authorization and label-based access control, so the platform itself handles part of the access decision that an open-source deployment leaves to your proxy. This can reduce the amount of custom authorization code you write, but the division of responsibility still needs to be defined in your design and tested.
- Token authorization: GEL supports token-based authorization as a documented feature, which you should compare with the token flow your customers already use.
- Label-based access control: Access can be restricted by label, which matters when one customer should see only some streams, such as a single environment.
- Policy ownership: Someone must still define, review and version the access rules, and that work does not disappear with the commercial product.
- Integration with your identity model: Confirm how GEL tokens relate to your customer identity provider and whether your proxy remains in the request path.
- Testing: Access rules need the same negative tests as any tenant boundary, including attempts to query around the label selector.
Ask Grafana Labs for the current GEL access control reference and confirm how it behaves with your intended client setup before you design around it.
Operators of a multi-customer platform often need to query across tenants for incident response, capacity planning or support investigations. The GEL documentation lists cross-tenant queries as a commercial feature. In open-source Loki, a query carries one tenant ID, and combining tenants is not a built-in capability, so operators typically use separate queries, separate Grafana data sources or a custom approach. The choice affects both your support workflow and your audit posture.
- Operator access: Cross-tenant queries should be limited to a small, named group, with every use logged.
- Customer privacy: Your customer contracts and data processing terms should state whether operators may read across tenants and for which purposes.
- Audit evidence: Keep records of who ran cross-tenant queries, when and why, so the activity can be reviewed.
- Workflow cost: Without cross-tenant queries, support staff may run the same investigation once per tenant, which adds time to each incident.
- Separation of duties: Consider whether operators who can read across tenants should be different people from those who administer the proxy.
Before you decide, ask Grafana Labs how cross-tenant access is licensed and governed, and check your own contract obligations with customers.
GEL entered long-term support with version 3.6 and reaches end of life on February 1, 2029, according to the GEL documentation. For a managed service that will run for years, that date is a planning input: it tells you how long a given GEL line receives support and when an upgrade becomes mandatory. Open-source Loki is licensed under AGPLv3, which Grafana Labs announced on April 20, 2021, and that license has its own obligations for anyone who modifies and offers the software over a network. Choosing between the two paths is therefore partly a licensing and support decision, not only a technical one.
- Support window: Compare the GEL long-term support window with the upgrade cadence you can sustain for open-source Loki.
- Licensing obligations: Review AGPLv3 duties against any modifications you make to Loki and how you expose them to customers.
- Commercial terms: Ask for pricing structure, support levels and renewal terms in writing, and confirm whether they scale with tenants or data volume.
- Contract terms: Confirm how a switch between open-source and GEL would affect data, configuration and tenant IDs.
- Support scope: Confirm which support obligations Grafana Labs provides and which remain with your operations team.
Compare licensing and support terms directly with Grafana Labs using the current licensing page before you commit to either path.
What a multi-tenant Loki costs to build and run
The largest cost in a multi-tenant Loki is usually people's time, and most of it is one-time: designing the tenant model, building the authenticating proxy that maps customer credentials to X-Scope-OrgID, and wiring per-tenant limits and retention. Each of these is a fixed-scope piece of work you can price before it starts. The proxy and identity integration deserve the closest look, because Loki has no authentication layer of its own and the proxy is where a cross-customer leak would occur. Ask any partner to quote the proxy, the identity source, the onboarding automation and the security testing of tenant isolation as separate line items. Recurring costs begin once customers exist: onboarding and offboarding each new tenant, rotating credentials, and keeping the proxy and Loki current.
The recurring infrastructure costs are object storage for compressed chunks and the TSDB index, and compute for the write, read and backend components of your chosen deployment mode. Keep in mind that the simple scalable mode is being deprecated and will be removed with the Loki 4.0 release, so confirm which mode a quote assumes. Three drivers move these costs most: tenant count, daily log volume per tenant, and retention length. Retention is disabled by default, so a quote that does not state retention settings per tenant is incomplete. Compute for compaction and per-tenant usage monitoring also grows with the number of tenants, so ask how each is sized and what happens when one customer's volume spikes.
Licensing is the cost most often left out of the comparison. Open-source Loki is licensed under AGPLv3, so the software itself carries no license fee, but you should have counsel review what the AGPL means for your offering. If you choose Grafana Enterprise Logs, the commercial license adds token authorization, label-based access control and cross-tenant queries, and its price comes from Grafana Labs, which you should obtain in writing before you compare totals. Ask any partner to show the one-time build cost, the monthly run cost at your projected tenant count, and the cost of a customer exit, since the EU Data Act requires providers to support switching, which affects how much you spend on exports and onboarding in reverse.
Limits to confirm before you promise isolation to customers
Loki gives you tenant separation on the data plane, but several limits sit outside that boundary. Each one changes what you can promise a customer, who must build what, and which decisions are hard to reverse. Confirm these with Grafana Labs and your legal team before you put isolation language in a contract.
No built-in authentication
Loki does not authenticate callers. It trusts the X-Scope-OrgID header it receives, so anyone who reaches Loki directly can read any tenant. You must place an authenticating reverse proxy in front of it and make sure customers can never reach Loki's port or set that header themselves. Confirm your proxy design with a penetration test before you describe isolation to a customer.
Tenant IDs are stored data
Tenant IDs are written into stored chunks and index data, so renaming a tenant later is not a configuration change. It requires a data migration, which can be costly at scale. Settle your customer ID scheme, length and character rules before the first customer is onboarded, and ask Grafana Labs what migration options exist for your storage backend.
No label-based access control in open source
The open-source edition does not restrict which streams a tenant can query by label selector. Any user inside a tenant sees all of that tenant's logs. If a customer needs team- or environment-level restrictions inside its own tenant, you need a commercial option or a different tenant split. Confirm with Grafana Labs whether Grafana Enterprise Logs fits that requirement and what it adds in licensing terms.
Enterprise Logs docsSimple scalable mode is being removed
The simple scalable deployment mode, which many teams pick for mid-sized clusters, is documented as deprecated and will be removed with the Loki 4.0 release. A multi-tenant service built on it will need to move to monolithic or microservices mode before that release. Plan that migration into your roadmap and confirm the supported path for your scale with Grafana Labs.
Deployment modes docsAGPLv3 license obligations
Loki is licensed under AGPLv3, which carries source disclosure duties for modified versions that users interact with over a network. If you alter Loki or its integrations and offer them to customers as a service, those duties may apply to your code. Have your legal team review the license terms and the licensing page before you ship any modification to customers.
Grafana licensing pageMulti-tenant Loki questions buyers ask before hiring help
How much work does a multi-tenant Loki design take?
The work scales with how many customers you serve, how different their isolation needs are, and how much of the tenancy model must be built around your own systems rather than configured out of the box. Multi-tenancy starts with a single switch: Loki is multi-tenant when auth_enabled is true and identifies each tenant with the X-Scope-OrgID header on every request. The larger effort sits around that switch. You need a tenant ID scheme, a proxy that maps customer credentials to those IDs, per-tenant retention and limits, and a way to prove to customers that one tenant cannot read another's data. Each of these is a design decision with consequences for later onboarding and for any future migration. Ask any partner to list each component, the systems it touches and the tests that prove isolation before accepting a fixed scope.
Can our internal team build multi-tenant Loki without outside help?
A team with strong Linux, Kubernetes or cloud operations and some experience with Grafana tooling can build a working design, provided it has time to learn the storage, compactor and limits behavior from the official documentation. The risk is rarely the first deployment. It is the second and third years: upgrades, schema changes, retention edits and tenant growth all touch the same configuration. Before deciding, check whether you have an owner for the authenticating proxy, someone who can review the tenancy model with your security team, and capacity to test restores. If any of those are missing, a partner can fill the gap through a fixed-scope engagement, while your team keeps operating the cluster afterward.
What does DeployOpen need from our team to start?
Engagements need decisions and access from your side before any build begins. Expect to provide a list of customer segments and their isolation expectations, the identity provider that customers already use, the object storage account or cluster where Loki will run, and the data classes that will be stored. Your security and compliance leads should confirm retention periods and deletion requirements, because retention is disabled by default and logs are kept indefinitely until it is enabled. You should also name a person who can approve the tenant ID format and the proxy design. DeployOpen plans, implements, hardens and documents these systems inside your own cloud accounts, data centers or air-gapped networks, so the infrastructure, credentials and sign-off stay with you.
How long does onboarding a new tenant take?
Onboarding a new tenant takes as long as the slowest step in your process, which is usually identity mapping, limits review and log shipping rather than the Loki change itself. Adding a tenant involves assigning an ID that follows your naming rules, creating the credential mapping in the proxy, setting per-tenant retention and limits, and configuring the customer's collector to send the correct X-Scope-OrgID header. If your limits are managed through a runtime overrides file, the change can apply without a restart, but it still needs review. No supplied figure fixes a duration, so ask any partner for the steps, the approvals each step needs and the test they run to confirm the tenant sees only its own streams. Document those steps as a runbook before the first customer goes live.
What drives the cost of a multi-tenant Loki engagement?
Cost is driven by scope, not by the number of tools installed. Scope covers the number of customer segments, the depth of isolation required, how many identity sources the proxy must trust, the retention rules you must prove, and whether the design must satisfy external reviews. Cost has one-time parts, such as design, build, hardening and testing, and recurring parts, such as upgrades, on-call support, limit changes and continuous testing, which can be arranged as a retainer. Your own infrastructure costs for storage, compute and networking are separate and billed by your cloud or hardware provider. DeployOpen does not publish a price list. Ask for a written quote that lists each deliverable, the assumptions behind it and which items recur.
When is Grafana Enterprise Logs worth evaluating over open-source Loki?
Grafana Enterprise Logs is worth evaluating when your requirements go beyond what open-source Loki provides on its own. According to the Grafana Enterprise Logs documentation, GEL adds token authorization, label-based access control and cross-tenant queries, and it entered long-term support with version 3.6 and reaches end of life on February 1, 2029. Consider it if customers need label-level restrictions enforced by the platform, if your operators need cross-tenant views, or if you need a supported long-term release line. Open-source Loki remains licensed under AGPLv3, which your legal team should review against how you offer the service to customers. Confirm licensing terms, support scope and feature availability with Grafana Labs before deciding.
Does Loki handle customer authentication by itself?
No. Loki has no built-in authentication layer, so you must place an authenticating reverse proxy in front of it. The Loki authentication documentation names nginx, HAProxy, OAuth2 Proxy and Pomerium as examples. The proxy verifies the customer's credential, then sets the X-Scope-OrgID header that identifies the tenant. If that mapping is wrong, one customer can read another customer's logs, so the proxy is the most security-sensitive part of the design. Reviewers will ask how the header is set, whether clients can overwrite it, how credentials are rotated, and how access is logged. Plan testing that tries cross-tenant reads with forged headers before any customer goes live.
What evidence do customers and auditors usually request for tenant isolation?
Customers and their auditors typically ask for a description of the tenancy model, the mapping between customer identities and tenant IDs, the retention settings applied per tenant, the access logs for the proxy, and the results of isolation tests. Auditors examining a SOC 2 engagement reference the AICPA 2017 Trust Services Criteria, where the security common criteria CC1 to CC9 apply to every report. A SOC 2 Type 1 report describes the design of controls as of a date, while a Type 2 report adds an opinion on operating effectiveness over a period. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports or certifications. Independent auditors and certification bodies do that work.
How DeployOpen scopes and delivers a multi-tenant Loki
DeployOpen plans, implements, hardens, documents and supports self-hosted Loki inside your own infrastructure, including the tenant model, the authenticating proxy and retention for each customer or team. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
How we scope
- We confirm whether each tenant maps to a customer, team or environment, and document the tenant ID rules before any build.
- The written scope lists the proxy design, per-tenant retention and limits, and the Grafana access model for your customers.
- We identify which features need Grafana Enterprise Logs, such as label-based access control, and which the open-source build covers.
How we build
- We deploy Loki with auth_enabled set, and place an authenticating reverse proxy in front that sets X-Scope-OrgID from verified customer credentials.
- We configure retention per tenant and per stream selector in the compactor, and confirm the deletion behavior with test data.
- We set per-tenant ingestion and query limits, and test shuffle sharding so one noisy customer cannot degrade others.
How we hand over
- You receive the architecture record, tenant register, proxy configuration and limit and retention settings as documentation.
- We provide isolation test results showing that one tenant cannot read another tenant's logs through the proxy or Grafana.
- Runbooks cover adding a tenant, changing limits, rotating proxy credentials and removing a tenant's data under your retention policy.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Upgrade planning covers Loki version changes, including the removal of simple scalable mode in Loki 4.0, before your tenants are affected.
- Retesting of tenant isolation follows proxy changes, Loki upgrades and new customer onboarding, as agreed in the retainer scope.

