Why Loki recording rules with remote write matter for dashboards and alerts
A team whose dashboards or alerts run LogQL metric queries over large log volumes often sees the same query re-scanning hours of logs every time a panel refreshes or a rule fires. Loki recording rules fix this by moving the work to a schedule: the ruler evaluates a LogQL metric query at a set interval, stores the resulting samples, and remote-writes them to a Prometheus-compatible backend such as Prometheus, Grafana Mimir or Thanos. Dashboards and alerts then read a time series that is already computed, instead of asking Loki to read the raw chunks again.
Per the Loki recording rules documentation, the ruler queries the store directly while respecting querier limits, so its evaluations compete with interactive queries for the same capacity. Precomputing is worth the effort when the same expensive aggregation is shared by many panels or rules, when a query is slow enough to delay alerts, or when long-term trends must outlive the log retention period. It is usually not worth it for one-off investigations, for queries whose results change with every new label value, or for logs you only search occasionally. Before building rules, confirm with your own data which queries are repeated and how long they take, and check that the chosen backend's retention and query path meet the dashboards that will read the results.
Recording rules add state that must be operated. Samples produced by the ruler pass through a write-ahead log, which the documentation says protects data if the ruler crashes, at the cost of extra memory and slower start-up. Plan for that memory and restart time when you size the ruler, and confirm how your remote-write target handles gaps, duplicate samples and backfill after an outage. Also decide who owns the rule definitions, since a change to a recording rule alters every dashboard and alert that depends on its metric name. Treat rule files as reviewed configuration with a named owner, and test each rule against a known time range before it feeds an alert.
How the ruler moves recorded samples from Loki to a metrics backend
The flow starts with the Loki ruler, which loads rule groups and evaluates each LogQL metric query against the store while respecting querier limits. Each resulting sample is first written to the ruler's write-ahead log, so a crash does not discard it, and then sent by remote write. The trust boundary sits at the remote write endpoint, where the tenant header identifies the owner of the series. Check that the tenant ID matches on both sides, and that Grafana reads the same backend the ruler writes to.
Recorded samples flow from the ruler through its WAL to a metrics backend across a marked trust boundary.
Choosing a Prometheus-compatible backend for remote write
A single Prometheus server with persistent disk is the simplest target for recording rule output. The ruler pushes samples through remote write, and Prometheus stores them in its local time series database. That database is organized into two-hour blocks with a write-ahead log, and its default retention is 15 days, configurable by time or size. The Prometheus storage documentation states that local storage is not clustered or replicated and should be managed like any other single-node database, so the team owns backups, disk sizing and restore testing.
- Retention ceiling: Plan retention in time or size against disk capacity, because the default 15 days may not match audit or trend needs.
- Single point of failure: A lost server means lost stored samples unless disks and restores are tested.
- Upgrade ownership: Your team schedules Prometheus minor and LTS upgrades against the release cycle.
- Low operating surface: No object storage, tenant headers or separate components are required.
- Scale limit: Growth in series count or query load usually drives a move to a distributed backend.
Before choosing this option, confirm the disk size, retention window and recovery time your compliance and dashboard owners expect.
Grafana Mimir provides horizontally scalable, highly available, multi-tenant long-term storage for Prometheus, and it is distributed under AGPL-3.0-only. Prometheus writes to Mimir through the remote write API to the distributor, and PromQL queries go to the query frontend. Each tenant's series are stored in their own Prometheus TSDB in object storage. Mimir 3.0 introduced a preferred ingest architecture that uses Kafka as a central pipeline to decouple reads from writes, while the classic architecture uses stateful ingesters with local write-ahead logs.
- Tenant separation: Mimir requires a tenant ID header on every HTTP request, so the ruler's remote write must set it consistently.
- Authentication is external: Mimir leaves authentication and authorization to a reverse proxy you must deploy and operate.
- Ingest architecture choice: Decide between the Kafka-based architecture from Mimir 3.0 and the classic ingester design before sizing.
- Object storage dependency: Supported stores include Amazon S3, Google Cloud Storage, Microsoft Azure Storage, OpenStack Swift and a single-node local filesystem.
- Kubernetes packaging: The mimir-distributed Helm chart installs, configures and upgrades Mimir in a cluster.
Confirm the expected active series count, the ingest architecture and the tenant model with the Mimir architecture documentation before committing to a design.
Thanos Receive suits teams that already run Thanos. It implements the Prometheus Remote Write API for setups where Prometheus pushes metrics, and it uploads TSDB blocks to object storage every 2 hours by default. Tenants are identified by the THANOS-TENANT header by default, so the ruler's remote write configuration must match your tenant scheme. Thanos is built as a distributed system and is not recommended for production on a single node, so Receive belongs in a cluster you already operate.
- Existing investment: Adoption is most practical when Query, Store and Compactor already run in your environment.
- Block upload cadence: Blocks reach object storage on a two-hour cycle, which shapes how fresh historical data appears in queries.
- Compactor singleton: The compactor must run as a singleton per object storage bucket and downsamples data older than 40 hours to 5-minute resolution.
- Operational breadth: Receive, Query, Store, Compact and Rule each add components that need monitoring and upgrades.
- Version tracking: Thanos has recent releases in 2026, so confirm the version your environment targets against the releases page.
Before choosing Receive, confirm with your platform team that the existing Thanos components, bucket layout and tenant header scheme fit the ruler's output.
Ruler and remote write configuration options and when each fits
This table compares the ruler and remote write settings that shape a Loki recording rule deployment, from rule group intervals and the WAL to tenant identification and backend retention. Read each row as a decision: the right column names when the option fits and what to confirm in the vendor configuration reference before you set it.
| Setting | What it controls | When it fits | What to confirm |
|---|---|---|---|
| Rule group interval | How often the ruler evaluates each recording rule group and writes the resulting samples | Shorter intervals suit dashboards that need fresh values; longer intervals reduce query load on the store and the ruler | Confirm the default evaluation interval and the querier limits that apply to ruler queries in the Loki configuration reference |
| Write-ahead log enabled | Writes recording rule samples to a WAL so a ruler crash does not lose data | Choose it when gaps in precomputed series would break alerts or long-term dashboards | Confirm the WAL directory, its disk requirements and how start-up time changes with your sample volume |
| Write-ahead log disabled | Sends samples without a local WAL, so samples in flight can be lost on a ruler crash | Acceptable for short-lived or easily regenerated series where memory and start-up time matter more than continuity | Confirm how gaps appear in the receiving backend and whether your alerts tolerate them |
| WAL memory and start-up cost | Extra memory held while samples are buffered and replayed time spent when the ruler restarts | Plan for it when many rule groups or high-cardinality outputs run in one ruler | Ask for the WAL memory behavior at your expected rule count and test a restart in a non-production environment |
| Tenant identification | Which tenant the ruler writes to, and how the receiving backend separates that tenant's series | Required when several teams share one Prometheus-compatible backend, such as Mimir or Thanos Receive | Confirm the tenant header name for your backend: Mimir requires a tenant ID header on every request, and Thanos Receive uses the THANOS-TENANT header by default |
| Retention on the receiving backend | How long precomputed series are kept after they reach Prometheus, Mimir or Thanos | Set it to match the dashboard and alerting lookback you need, since Loki log retention does not govern metric retention | Confirm the retention settings of your chosen backend, such as Prometheus default local retention, and the object storage lifecycle for Mimir or Thanos |
| Remote write endpoint and authentication | Where the ruler sends samples and how it proves its identity to the receiver | Use a path that the receiver's reverse proxy can authenticate, because Mimir and Thanos leave authentication to an external proxy | Confirm the remote write URL format, credential handling and TLS settings in the Loki and receiver references |
| Downstream compaction and downsampling | Whether the receiving backend reduces resolution of older series over time | Useful when long-term trend data matters more than full resolution after a few days | Confirm which compactor runs, its singleton requirements and the resolution rules that apply to your bucket |
Setting up recording rules and remote write step by step
This sequence takes a self-hosted Loki ruler from a confirmed deployment mode and tenant setup to a recording rule that writes samples to a Prometheus-compatible backend, with a persisted WAL that protects those samples across restarts.
Confirm deployment mode and authentication settings
Your platform or Loki owner checks which deployment mode runs the ruler (monolithic, simple scalable or microservices) and confirms whether auth_enabled is true, since that setting determines whether tenants exist at all. Note that the Loki docs say simple scalable mode is being deprecated and removed with the 4.0 release, so a new build should favor a supported path. Done means you have a written record of the mode, the auth_enabled value and the tenant ID the rules will use, and that the ruler runs as its own target you can restart.
Write recording rule files for one tenant
Create a rule file for a single tenant, using the tenant's X-Scope-OrgID value as the directory and group boundary. Each group holds a LogQL metric query that is expensive to run on every dashboard load, with a clear record name and labels that match what the receiving backend will store. Keep the first set to one or two rules so you can confirm behavior before scaling. Done means the rule file loads without parse errors and the ruler lists the group as healthy in its status view.
Configure the ruler remote write target and WAL
In the Loki configuration, set the ruler's remote write client to the URL of your Prometheus-compatible receiver, such as Prometheus, Mimir or a Thanos Receive endpoint, and set the tenant header that receiver expects. Enable the ruler write-ahead log and point it at a directory on persistent disk, not a container's ephemeral layer. The WAL trades extra memory and slower start-up for protection against ruler crashes, so size memory with that in mind. Done means the ruler starts with the remote write client reporting a configured target and the WAL path exists on the host.
Point the receiving backend at the tenant
On the receiving side, confirm the backend accepts remote write for the same tenant ID the ruler sends. For Mimir, the distributor takes writes and the tenant header must match the one in your Loki setup. For Thanos Receive, tenants are identified by the THANOS-TENANT header by default. Confirm authentication sits in a reverse proxy in front of the receiver, because Mimir and Thanos leave authentication to that layer. Done means a test write with the same tenant header succeeds and the series appears under that tenant only.
Verify samples arrive from the ruler
Restart the ruler's evaluation on the recording rule group, then query the backend for the new series name using the tenant's query path. Compare the value against the same LogQL expression run directly in Grafana for the same time window, accepting that the backend stores samples on its own schedule. Check the ruler's remote write error metrics and logs for rejected or retried batches. Done means the recorded series returns values over at least one evaluation interval and the ruler reports no sustained write errors.
Confirm the WAL directory survives a restart
Stop the ruler cleanly, confirm the WAL directory still contains segment files, then start the ruler again and check that it resumes writing without a gap in the recorded series beyond the outage itself. Repeat the check after a forced termination in a test environment to see how the WAL replays. Check that the WAL path is on a volume that persists across container or node replacement. Done means a restart cycle leaves the WAL in place, the ruler resumes, and the backend shows continuous samples for the rule.
Record the setup for operations and upgrades
Write down the deployment mode, tenant ID, rule file locations, remote write URL, WAL path and the verification queries used above, so the on-call team can repeat the checks after an upgrade. Note that the 4.0 change wipes the ruler's remote write WAL on startup, so plan for that before moving to a newer major version. Done means a reviewer who was not part of the build can find each setting and re-run each check from the record alone.
What the ruler WAL protects and what it costs
The ruler write-ahead log (WAL) exists for one reason: samples produced by recording rules are written to disk before they are sent to the remote write backend, so a ruler crash does not silently lose the metric points it had already computed. Without it, a restart would leave a gap in the precomputed series that the query over the same window cannot fill, because the raw logs may have aged past the point where recomputing them is cheap. The cost is paid in two places. The WAL uses extra memory and disk I/O while the ruler runs, and on start-up the ruler must replay the log before it resumes evaluation, which delays the first rule cycle. Size the ruler's memory and disk with the WAL included, and test a restart under realistic sample volume rather than assuming start-up time is negligible.
Replay affects timing as well as data. While the WAL is replayed, rule groups are not evaluated on schedule, so a dashboard or alert that depends on a recording rule may show a delayed or stale value for the duration of the replay. Plan for this by checking how many rule groups and series your ruler carries, measuring replay time in a staging environment, and deciding whether alerts that depend on recorded series need a for duration or a no-data policy that tolerates a restart window. The WAL protects only what it has written, so it must sit on persistent storage that survives pod or host rescheduling. An ephemeral volume turns the WAL into a false sense of safety. In Kubernetes, confirm the volume claim and mount path in your chart values before go-live.
WAL behavior is not fixed across Loki releases. Storage location, replay handling and the conditions under which the WAL is kept or discarded have changed between versions, and the ruler's remote-write WAL is one of the areas named in the Loki ruler operations material as changing in the 4.0 line. Before you upgrade or pin a version, read the upgrade notes for both your current and target releases and confirm the WAL settings they require. Keep a documented test that stops and restarts the ruler, then checks that recorded series have no unexpected gap. Repeat that test after every version change, because a passing test on the old release does not prove the new one keeps the same guarantee.
Security and operational risks of recording rules
Recording rules move log-derived samples out of Loki and into a Prometheus-compatible backend, so the risks sit at the boundary: who can write, which identity is claimed, what credentials the ruler holds and how much load evaluation puts on the store. The cards below cover the controls to verify before the rules run in production.
Unauthenticated remote write endpoints
Loki and Grafana Mimir do not provide their own authentication layer, so a remote write endpoint that is reachable without a reverse proxy accepts samples from anyone who can reach it. Put an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of each write path, and confirm that the ruler's write target is not exposed directly on a network segment your users can reach. Test the endpoint from outside the approved network before go-live.
Loki authentication docsTenant ID header spoofing
Loki identifies tenants with the X-Scope-OrgID header, and Mimir requires a tenant ID header on every request. Both systems trust whatever header arrives, so the proxy must overwrite or strip client-supplied tenant headers and set the tenant itself based on the authenticated identity. Without this, a client can write recorded series into another team's tenant or read another tenant's data.
Loki multi-tenancy docsCredentials for the remote write target
The ruler must authenticate to the Prometheus-compatible backend, which means a token, password or client certificate is stored where the ruler can read it. Keep these secrets out of rule files in Git, scope each credential to a single tenant and write path, and plan rotation. Ask who issues and revokes the credential, and confirm that the ruler's configuration and logs do not echo it.
Sample accuracy under failure
Prometheus values reliability over precision and is not a good choice where 100% accuracy is required, so a recorded series used for billing or audit evidence needs a different source of truth. Recording rules that aggregate log counts can also drift when samples are lost or re-evaluated over a gap. Decide which series are operational signals and which need exact counts from the logs themselves, and document that boundary for the people who read the dashboards.
Prometheus overviewRuler load on the store
The ruler queries the store directly while respecting querier limits, so every recording rule runs its LogQL expression on each evaluation interval. Broad selectors over high-volume streams can slow ingest and query traffic for other users. Review the query cost of each rule before deployment, keep selectors narrow, and confirm the querier limits that apply to ruler tenants in your configuration.
Single writer for the Thanos compactor
If the metrics backend is Thanos, the compactor must run as a singleton against each object storage bucket. Running two compactors against the same bucket risks corrupting block data, so deployment tooling and Kubernetes replica settings must enforce one instance. Check this during every upgrade or scale change, and pair it with the Prometheus block setting that disables local compaction when the sidecar uploads blocks.
Thanos compactor docsWhat recording rules and remote write cost to implement and run
What drives the cost of running Loki recording rules with remote write?
The main cost drivers are the number of recording rules, how expensive each LogQL query is over the data it scans, which backend receives the samples, how much WAL storage the ruler needs, and the staff time to build and operate the pipeline. Each rule runs on a schedule and reads from the store, so more rules and wider time ranges increase query load on the querier and object storage. The backend choice changes the infrastructure you pay for: a single Prometheus server, a Grafana Mimir cluster or a Thanos deployment each carries different compute, storage and operations costs. Ask for a quote that lists rule count, evaluation intervals, target backend and retention for the stored series so the estimate reflects your actual load.
Which recording rules costs are one-time and which are recurring?
One-time costs include the design of rule groups, the backend selection, the initial configuration, migration of any existing dashboards or alerts that will use the precomputed series, and testing that the stored samples match the original LogQL results. Recurring costs include the cloud compute and object storage for the ruler, the backend, and the queries it answers, plus WAL disk, backups, version upgrades and the staff time to watch evaluation errors and remote write failures. Most of the recurring cost comes from infrastructure you already pay for, so the long-term budget depends on how many series you retain and for how long. Ask the provider to separate one-time build work from an ongoing support arrangement so you can budget each line on its own.
Can an internal platform team build Loki recording rules without a partner?
Yes, a team with experience running Loki and a Prometheus-compatible backend can build this in-house, provided it has someone who understands LogQL metric queries, remote write behavior and object storage. The work is less about writing rule files and more about sizing the ruler, deciding how samples are stored, setting up alerting on failed remote writes and testing restarts. Teams without that experience usually spend time on the WAL trade-offs, multi-tenant header design and backend configuration. A partner can work as a fixed-scope build with written deliverables, or as a review of a design your team has already drafted, and you can compare both options against your staffing.
How long does a recording rules build take, and what changes the timeline?
The timeline depends on scope rather than on the Loki feature itself. A small set of rules writing to an existing Prometheus server is a much smaller job than rules feeding a new Grafana Mimir or Thanos deployment with tenant separation, object storage and alerting on the pipeline. Other factors include how many existing LogQL queries need conversion, whether the backend already exists, how much testing is needed to prove the stored series match the originals, and how quickly your security team reviews the design. Ask for a written schedule that breaks the work into design, build, validation and handover, and confirm which dependencies sit with your team.
What does the WAL add to the cost and operations of the ruler?
The ruler writes generated samples to a write-ahead log so a crash does not lose them, which costs disk space, extra memory and slower restarts. The WAL grows with the sample rate and is only useful if it is on storage that survives the ruler pod or host, so you pay for that persistent volume and for monitoring its size. Plan for the cost of replaying the WAL during start-up, which affects how quickly alerts and recording rules resume after a restart. Confirm the WAL settings and volume sizing against your sample rate before the build, because changing them later can require a restart window.
What do we need to provide before a recording rules engagement starts?
You need to provide access to the cloud accounts, Kubernetes clusters or servers where Loki, the ruler and the backend will run, plus object storage buckets and credentials managed under your own controls. Tenant design matters early: you must decide how the X-Scope-OrgID header maps to teams or environments and who can query each tenant's stored series. You also need a list of the LogQL queries to precompute, their intended dashboards or alerts, the retention you require, and named contacts in security, networking and platform operations who can approve changes. Without these inputs, scope and cost estimates are not reliable.
What ongoing staff time does a recording rules pipeline need?
Ongoing staff time goes to watching ruler evaluation errors, remote write failures, WAL growth and backend health, applying Loki and backend upgrades, and reviewing new rules before they are added. The amount depends on how often rules change, how many tenants share the backend and whether you run alerting on the pipeline itself. Upgrades are a recurring effort because the ruler and backend versions move independently, and each change needs a test against the stored series. Ask any partner for a support model that states response expectations in writing, and confirm what your own team must still cover.
Does the backend license or vendor choice change the total cost?
Prometheus is Apache-2.0 licensed with no paid enterprise edition, so its license adds no direct fee, but its single-node storage means you must plan capacity, backups and retention yourself. Grafana Mimir is licensed under AGPL-3.0-only, and Thanos is Apache-2.0 licensed, so you should have your legal team confirm how the license applies to your deployment and whether you will modify the code. The total cost still depends on infrastructure, storage and staff time for whichever backend you choose. Ask for a comparison that lists compute, object storage, operations hours and license review for each option before you decide.
Keeping recording rules working through Loki and backend upgrades
Treat the ruler's rule files, remote write settings and WAL configuration as versioned infrastructure that moves through the same change process as Loki itself. Keep rule groups and the remote_write block in Git, tag each change with the Loki version it was tested against, and promote it through a staging environment that points at a non-production copy of the backend. The point is to catch the situations where a Loki upgrade changes how a LogQL expression evaluates or how the ruler handles its WAL, and where a backend upgrade changes what it accepts on the remote write path. Before any Loki minor or major upgrade, read the upgrade notes for the ruler and recording rule behavior and confirm them against your own rules, because the official Loki recording rules documentation is the reference for the expected behavior of your version.
The backend has its own clock. Prometheus publishes a new minor release every 6 weeks, and a minor release generally stops receiving bug fixes after those 6 weeks, while long-term support lines receive bug fixes for one year. Check the Prometheus release cycle page for the current LTS line and its end date, then choose a backend version that stays inside a supported window for the whole period you plan to run it. For Mimir or Thanos, confirm the same question against each project's release page, because their version lines and support windows differ from Prometheus. Put backend upgrades on a calendar, test the recording rules after each one, and record which Loki, ruler and backend versions were running together so that a failure can be traced to one change.
If the backend changes, for example from a single Prometheus server to Mimir, plan the switch as a migration rather than a configuration edit. The Mimir documentation includes a guide for migrating from Thanos or Prometheus, which should be the starting point for the data move and cutover. During the switch, run the ruler against both targets for a period, compare the produced series with each other, and confirm that the tenant header and labels match what dashboards and alerts expect. Ask your Loki and backend owners to confirm how the WAL is handled during the cutover, and keep the old backend readable until historical queries and alerts have been verified on the new one.
How DeployOpen scopes and delivers Loki recording rules
DeployOpen plans, builds and hands over Loki recording rules that run in the ruler and push results to your Prometheus-compatible backend through remote write, inside infrastructure you control. Each engagement starts from a written scope that names the rules, the backend, the retention targets and the people who will operate them.
How we scope
- Inventory the LogQL metric queries that are slow or costly enough to precompute, and record which dashboards and alerts depend on them.
- Confirm the target backend, whether Prometheus, Mimir or Thanos, along with its tenancy model, ingest path and storage location.
- Agree in writing the rule groups, evaluation intervals, ruler WAL settings, crash recovery expectations and the Loki version in scope.
How we build
- Configure the ruler with rule files, remote write settings and tenant mapping so recorded samples reach the agreed backend.
- Enable the ruler WAL, then test a controlled ruler restart to confirm samples survive and measure the start-up delay in your environment.
- Check recorded series against the original LogQL results over a defined window, and confirm querier limits are not exceeded during evaluation.
How we hand over
- Deliver the rule files, backend configuration and access settings in your own version control, with deployment steps documented for your team.
- Document the WAL trade-offs, memory and start-up effects, and the verification steps your operators should repeat after upgrades.
- Walk your platform and observability teams through monitoring of remote write failures, rule evaluation errors and backend ingestion.
How we support
- Engagements are fixed-scope, so changes to rules or backends are agreed as written scope changes before work starts.
- Ongoing support, version upgrades and continuous checks of recording rule output are available as a retainer.
- Before upgrading Loki or the backend, we review release notes and retest the ruler WAL and remote write path in a staging environment you control.

