Why busy Loki streams hit the rate limit and how automatic stream sharding helps
Loki splits busy streams automatically by adding labels, keeping each shard under desired_rate, which sits below the per_stream_rate_limit. A single source, such as one application instance or a noisy container, sends every line under one label set, so all of its traffic lands in one stream. When that stream's ingestion rate exceeds the per-stream limit, Loki rejects the excess writes, and the sender sees errors or dropped lines even though the cluster as a whole has spare capacity. Automatic stream sharding addresses this specific case by letting Loki distribute the stream's traffic across several internal streams that differ by an added label, so each one stays within bounds.
Teams usually need this when one source is legitimately chatty, for example a batch job, a busy ingress controller or a service that logs every request at debug level, and the team cannot reduce the volume at the source. Check first whether the rate limit errors are coming from one stream or from many, and whether the labels on that stream are sensible. Sharding is not a fix for poor label design upstream. If pod names, user IDs or request IDs are used as labels, the stream count will keep growing and sharding will add more streams on top of an existing cardinality problem. Confirm your label set with the guidance in the sibling topics before you tune sharding, and confirm the current defaults for desired_rate and per_stream_rate_limit in the Loki automatic stream sharding documentation for your Loki version.
Sharding settings and when each one fits
This table compares the three settings that control automatic stream sharding: the on/off switch, desired_rate and per_stream_rate_limit. Read each row for what the setting controls, its default, and the situations where a team would change it. The main takeaway is that desired_rate sits below the per-stream limit, so sharding acts before ingestion starts rejecting a busy stream.
| Setting | What it controls | Default and when to change it |
|---|---|---|
| Automatic stream sharding (enabled by default) | Lets Loki split a busy stream into several streams by adding labels, so no single stream grows past the rate target. | Enabled by default. Change it only if you have measured that splitting is causing a problem, and confirm the setting name for your Loki version. |
| desired_rate | The per-stream rate Loki aims to keep each shard under before it adds another shard. | Default 1536KB. Lower it if downstream consumers or query workers struggle with large shards; raise it only after confirming the per-stream limit allows it. |
| per_stream_rate_limit | The hard ceiling on how fast a single stream may ingest before Loki rejects its lines. | Default 3MB. Raise it only for a known high-volume stream, and keep it above desired_rate so sharding has room to act first. |
| Headroom between desired_rate and the limit | The margin that lets sharding split a stream before ingestion errors begin. | Default gap is 1536KB below 3MB. Narrow it and sharding has less room to react; widen it only with a clear reason. |
| Labels available for splitting | The extra labels Loki can add when it shards, which determine how finely a stream can be divided. | Depends on your label design. Confirm which labels are bounded and safe to add, because each new value creates a new stream. |
How desired_rate relates to per_stream_rate_limit
The desired_rate setting is the target throughput Loki aims for in each shard of a stream, and it sits deliberately below the per_stream_rate_limit. The default desired_rate is 1536KB, while the default per_stream_rate_limit is 3MB. That gap is the headroom a stream has before ingestion starts rejecting data. When a stream's rate climbs toward the target, Loki splits it into more shards so each one carries less, and the limit only becomes the hard ceiling if sharding cannot keep up. Confirm both values in the configuration reference for your Loki version before you change either one, because defaults can differ between releases.
Setting desired_rate too low gives each shard more room, but it multiplies the number of streams. Every extra shard is a separate stream that Loki must index, track and compact, so a very low target can push index size and ingester memory up for no real gain in stability. Setting it too high does the opposite: fewer shards and a leaner index, but less margin when a burst arrives, so a busy stream can reach the per-stream limit and start losing lines. The practical question is how much burst a given stream produces. Measure its typical and peak rates over a representative period, then choose a target that leaves room for the peaks you observe.
Treat the two settings as a pair when you review limits. Changing per_stream_rate_limit without revisiting desired_rate can leave sharding either inactive or too aggressive, and a tenant-level override may set one value without the other. Ask your team or partner to record the chosen targets alongside the limits for each tenant, and check them again after any Loki upgrade, since sharding behavior and its defaults are part of the configuration that upgrade guides ask you to review.
Setting up and verifying automatic stream sharding
This sequence confirms that Loki's automatic stream sharding is active, sets the desired rate and tenant limits to match your workload, applies the change, and proves with a test stream that busy streams are split into shards without rate-limit rejections.
Confirm the Loki version and sharding default
Start by recording the Loki version running in each cluster, since the settings and behavior you check depend on it. Automatic stream sharding is enabled by default, so you are confirming that nobody has turned it off in the configuration your team deploys. Review the running configuration for any override of the sharding behavior and note the per_stream_rate_limit in effect. Your platform team or the Loki release notes for your version are the sources to confirm the exact setting names available to you. This step is done when you have a written record of the Loki version, the effective per-stream rate limit, and no explicit disablement of sharding.
Review the desired rate against the stream rate limit
Compare the desired_rate setting with per_stream_rate_limit. Loki's default desired_rate is 1536KB, which sits below the default per_stream_rate_limit of 3MB, leaving headroom so that sharded streams stay under the hard limit. Decide whether your busiest sources need a different value, and only lower or raise it after checking the effect on how many shards each stream creates. Keep the relationship between the two values intact: desired_rate should stay below per_stream_rate_limit. Confirm the chosen values with the team that owns the Loki configuration. This step is done when you have a documented pair of values and a reason for any change from the defaults.
Set per-tenant limits where workloads differ
If several teams or environments share one cluster, decide whether their limits should differ. Per-tenant overrides let a high-volume tenant have different ingestion settings without changing the defaults for everyone else. Apply these in the overrides configuration for the tenant identified by its X-Scope-OrgID, and only where a workload has a measured need. Keep changes small and record each override with its owner. Confirm the overrides load by reading the running configuration after a restart or reload, as your deployment method requires. This step is done when each tenant with a non-default value has a named owner and the effective values are visible in the running configuration.
Apply the change to the write path
Roll the configuration out to the components that handle ingestion. In a simple scalable or microservices deployment, this means the write path components, which are the ones that receive pushed logs and apply the rate limit. Use your normal change process, such as a Helm values update or a configuration file rollout, and restart or reload the components so the new values take effect. Check that every write replica reports the same configuration, because a replica running old values will reject or split streams differently from its peers. This step is done when all write components are on the new configuration and none are left on the previous version.
Send a test high-rate stream
Create a controlled test that pushes a single stream above the desired rate for a short period. Use a dedicated test label set, such as an identifying test label, so the traffic is easy to find and remove later. Send it through the same agent or client path your production sources use, such as Grafana Alloy, so the test exercises the real path. Run the test in a non-production tenant if one is available. The purpose is to generate enough volume that sharding is required, so the test should be sized against your configured desired rate rather than an arbitrary number. This step is done when the test traffic has been sent and you have recorded its start and end times.
Confirm the stream split into labelled shards
Query the test stream in Grafana or through the Loki API and check for shard labels on the split streams. Automatic stream sharding adds labels to divide a busy stream, so you should see the original stream's entries distributed across more than one labelled stream. Compare the number of distinct streams for the test labels before and after the test. If the count did not grow under load, the stream was probably below the desired rate, or sharding is not active on the path you tested. Recheck the configuration from the first steps before concluding anything. This step is done when you have a query result showing the split streams and their shard labels.
Check write logs for rate-limit errors
Review the write component logs and the ingestion metrics for the test period. You are looking for the absence of rate-limit rejections for the test stream, since sharding should keep each stream under per_stream_rate_limit. Also check that the errors reported by your client, such as Grafana Alloy, do not show rejected pushes for the test labels. If rate-limit errors appear, reduce the desired rate or check whether the tenant limits were applied to the tenant that actually received the push. Keep the test and its results with the change record. This step is done when the write logs and ingestion metrics show no rate-limit rejections for the test stream, and the result is saved with the configuration change.
Remove the test traffic and record the result
Stop the test client, delete the test stream from your environment if your retention policy requires it, and confirm that production streams are unaffected by checking their ingestion rates and error counts over a normal period. Record the Loki version, the desired rate and any tenant overrides, the shard labels observed, and the write log review in your change record. Recording the values means the next person who tunes sharding can see what was tested and why. This step is done when the test traffic has stopped, production ingestion is normal, and the change record is complete.
Security and operational considerations for sharded streams
Automatic sharding changes how streams are counted, limited and queried, so the controls around them need the same attention as the sharding settings. The cards below cover tenant isolation, access control, monitoring and change management, and they assume that the write path is protected before any limit is tuned.
Cap each tenant's share
In a multi-tenant cluster, one tenant pushing heavy streams can consume shared ingester and distributor capacity that other tenants depend on. Set per-tenant ingestion and stream limits so a runaway source is contained to its own tenant. Check that every tenant has explicit limits in its runtime overrides rather than relying only on cluster-wide defaults, and confirm the values with a test push at expected peak volume.
Multi-tenancy docsAuthenticate every push
Loki has no built-in authentication layer, so an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium must sit in front of it. That proxy decides who can write to which tenant. Map each sender to one tenant ID in the X-Scope-OrgID header, and make sure clients cannot set that header themselves. Without this control, any client that can reach the write endpoint can write into any tenant.
Authentication docsReview labels created by shards
When sharding splits a stream, it adds a shard label to the stream's labels. Query access controls and any label-based policies written against the original label set may not match the new streams as expected. Before enabling sharding for a tenant, list which label-based rules, dashboards and query filters depend on the full label set, and test them against sharded data. Confirm how your access layer treats the extra label.
Monitor shard counts and rejections
A rising shard count shows that a source is growing, and rate-limit rejections show when sharding is no longer keeping up. Track both per tenant, along with ingestion error rates reported by the distributors and ingesters. Alert on sustained growth in rejected lines rather than on single spikes, and confirm that your monitoring stack can see per-tenant metrics before you rely on them for capacity decisions.
Change limits under control
Ingestion limits, desired_rate and per-tenant overrides change how much data the cluster accepts, so they belong in version control and a documented review. Record who approved each change, the reason, and the expected effect on shard counts and storage. Test changes in a non-production cluster first, and keep the previous values ready so a rollback is quick if a tenant starts dropping data.
When sharding is not enough and label design needs to change
Automatic stream sharding treats the symptom of a busy stream, not the cause that made it busy. Sharding splits a stream that exceeds desired_rate by adding labels, which keeps each piece under the per-stream limit. It does nothing about why the stream was so large in the first place. If a label carries values that keep multiplying, such as pod names, user IDs or request IDs, every new value creates another stream, and the number of streams grows without a ceiling. Sharding then has more work to do on every one of them, and the index grows with it. A rising shard count on a stream is a signal to review the label set, not a sign that Loki is coping.
Before you tune sharding further, check where the volume comes from. Look at which labels on the hot stream change most often and whether the same values reappear across the day. If the source is unbounded, such as a service that writes one stream per customer or per container instance, the fix belongs in the pipeline that attaches labels, not in the Loki limits. The sibling topics cover the next steps: Loki label best practices for choosing static, bounded labels, diagnosing high cardinality to find the labels that explode stream counts, and moving high-cardinality fields into structured metadata so they stay searchable without being indexed. Confirm which of those options your Loki version and schema support before you commit to a design change.
Plan the label change as a migration rather than a settings edit. Changing which fields are labels changes the streams that new data lands in, so existing queries and dashboards built on old label names will need review. Run the change on one tenant or one source first, compare stream counts and shard counts before and after, and confirm that the queries your teams depend on still return results. Treat the desired_rate setting as a safety net you keep in place while the labels are corrected, and revisit it only after the stream count has stabilized.
Questions buyers ask about Loki stream sharding
Is Loki automatic stream sharding turned on by default?
Yes, automatic stream sharding is enabled by default in Loki. It keeps streams under the desired_rate, which defaults to 1536KB, below the default per_stream_rate_limit of 3MB, by adding labels that split a busy stream into several smaller ones. You do not need to switch it on, but you should confirm in your own configuration that nothing overrides it, because a tenant or environment override can change the behavior. Check the Loki automatic stream sharding documentation for the settings that apply to your version.
How much tuning does stream sharding usually need?
Most clusters need little tuning, because the defaults already sit well below the per-stream rate limit. The effort rises when a few sources produce very high volume, when you have many tenants with different limits, or when sharding splits streams so finely that query and index overhead grows. The work is measuring per-stream rates, deciding whether a desired_rate change is justified, and testing the change against real ingest patterns. Ask any partner to explain how they will measure stream rates before agreeing to tune anything.
What cost drivers apply to an outside partner compared with an in-house team?
For a partner, the quote follows from the written scope, so the main drivers are the number of Loki environments, the number of tenants and limits to review, the volume and sources involved, and whether the work includes verification in your own infrastructure. For an in-house team, the cost is mostly staff time for learning the rate-limit model, testing and ongoing monitoring, plus any incidents caused by tuning mistakes. Ask for a quote that separates the initial review from any recurring monitoring, since a one-time check and an ongoing retainer cost different amounts of effort.
What does the work need from our team?
You will need someone who can answer which log sources are busy, which tenants own them, and whether any service has a business need that conflicts with a limit change. Your team should also provide read access to the Loki configuration, a way to view ingest rates and limit errors in your monitoring, and a test window where a change can be observed. Without these inputs, any tuning decision rests on guesses about traffic, which is the most common reason sharding work stalls.
Can we handle stream sharding without a partner?
Yes, a capable platform team can review sharding settings using the official Loki documentation and its metrics. The decisions are contained: confirm the defaults are in effect, identify streams approaching the per-stream limit, and change desired_rate only with evidence. A partner adds value when the cluster is large, when multiple tenants have conflicting limits, or when your team lacks time to test changes safely. Decide based on your staff capacity and the risk of a misconfigured limit in production.
How long does verification take in different environments?
The duration depends on your environment, not on a fixed number. A single monolithic deployment with light traffic can be checked quickly, while a simple scalable or microservices deployment with many tenants needs more time to observe ingest across peak periods. Verification also depends on how long your busy sources take to show problematic rates, and whether you have a change window. Ask any provider for a written timeline tied to your deployment mode, traffic profile and access to test environments.
What changes after a Loki upgrade?
Upgrades can change defaults, limit handling and how Loki reports rate-limit errors, so sharding behavior should be rechecked after each version change. Review the upgrade notes for your target release, confirm the desired_rate and per_stream_rate_limit values still match your intent, and verify that sharding still splits busy streams as expected. Plan this check as part of the upgrade itself, not as a later task, and confirm the specifics for your version in the official documentation before you start.
Where to read the official stream sharding documentation
Start with the official Loki automatic stream sharding documentation before you change any stream settings, because the behavior depends on the Loki version you run. The page explains that automatic stream sharding is enabled by default and keeps streams under the desired_rate setting, which defaults to 1536KB, below the default per_stream_rate_limit of 3MB, by adding labels to split busy streams. Read it for the exact mechanics: which labels the sharding adds, how the desired_rate value relates to per_stream_rate_limit, and what Loki does with the stream once it is split. Confirm those default values against the page for your version, since your own limits may have been overridden in your configuration.
Next, check the Loki releases page on GitHub to see which version you run and what changed in it. Sharding behavior, default limits and configuration keys can change between releases, so compare your deployed version with the release notes for every version between your current one and your target. The most recent release listed there is v3.7.8, published September 17, 2026, but treat that as a starting point for your check, not a reason to upgrade. Use the release notes to confirm whether any sharding-related change affects your rollout, and record the version you validated against so later reviewers can reproduce the result.
Use the docs and release notes together with your own environment. Ask your team to confirm the effective per_stream_rate_limit and desired_rate values on every write component, the labels currently applied to your busiest streams, and whether any tenant has overrides. Note the version you tested against in your change record. If the official text and your observed behavior disagree, treat the observed behavior as the fact to investigate and raise the difference with Grafana support or your DeployOpen engineer before changing limits.
How DeployOpen scopes and delivers Loki sharding work
DeployOpen approaches automatic stream sharding in Loki as part of a wider self-hosted Loki deployment in infrastructure you control. The work starts from your actual stream rates and label set, so the desired_rate and per-stream limits are set against measured traffic rather than defaults alone.
How we scope
- The written scope lists which busy streams, tenants and log sources are included in the sharding review.
- Scope records the current per_stream_rate_limit, desired_rate and any tenant overrides on your Loki cluster.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
- Scope states who owns label choices, since sharding adds labels and those labels affect query cost.
How we build
- We check which streams approach the per-stream rate limit and record their ingest rates over a representative period.
- We set desired_rate and related limits in your configuration and test how streams split into shards.
- We confirm that shard labels stay bounded so sharding does not create new cardinality problems.
- We verify sharding behavior against ingestion metrics and error logs before changes reach production.
How we hand over
- You receive the configuration changes, the limit values chosen and the reasons behind each one.
- Documentation covers how to check whether sharding is working and which metrics show a stream being split.
- A runbook describes what to change when a stream again approaches its rate limit.
- A walkthrough with your platform and observability engineers confirms they can repeat the checks.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover.
- Retainer work can include reviewing stream rates after new log sources or Loki version upgrades.
- Support covers re-tuning limits when traffic patterns change, with changes documented and tested.
- Your team keeps ownership of the cluster, and we confirm the retainer scope in writing.

