Deleting specific log lines from Loki

Loki can remove log entries by stream selector, time window and line filter through the compactor's delete API. This page explains the modes, the cancellation period and the setup each deletion depends on.

On this page

When teams need to delete specific log lines from Loki

A secret, token or piece of personal data written to a log line is a case where hiding it is not enough. Loki stores compressed log chunks and an index in object storage, so a line that was ingested stays in those stored chunks until something removes it. Filtering it out of query results or dashboards leaves the original data in place. If the requirement is that the value no longer exists in the stored data, the team needs a deletion step, not a display change. Before anything else, confirm with your security and privacy owners exactly what must go, which streams it lives in and over what time window it was written.

Loki's compactor provides a delete API for this. A delete request names a stream selector, a time window and an optional line filter, and Loki removes matching log entries after a configurable cancellation period. That delay gives operators a window to cancel a request entered in error. Deletion is different from retention. Retention, set through the compactor and disabled by default, removes data once it ages past a configured period across a tenant or stream selector. Deletion targets specific entries regardless of their age, so it is the tool for a single leak rather than a policy for how long logs are kept.

Treat deletion as a planned, audited change rather than a quick fix. Each request should have a recorded approver, an exact selector and time range reviewed against a sample query, and a check of the tenant's deletion mode, since the deletion mode setting controls whether Loki only filters results or also removes data. Confirm with your Loki version and index configuration that the requirements are in place, including compactor retention, a configured delete request store and the TSDB index. Also plan for the copies the delete does not reach, such as upstream buffers, shipper queues and object store backups, and document how each one is handled.

Deletion modes and configuration options

This table compares the tenant deletion mode settings, the cancellation period, the delete request store and the selector inputs that define what gets removed. Read each row as a decision: what the setting controls, when it fits, and what it leaves behind. The main takeaway is that filter-only hides matching lines from queries, while filter-and-delete removes them from storage, so choose the mode based on what your privacy or audit obligations require.

SettingWhat it controlsWhen it fitsTrade-off to check
filter-onlyMatching lines are excluded from query results, but the stored chunks are not rewrittenQuick suppression of unwanted lines while you confirm the scope of the leakData still exists in object storage, so it may not satisfy a requirement to physically remove personal data
filter-and-delete (default)Matching lines are filtered from queries and removed from stored data during processingSecrets or personal data that must be gone from storage, not just hiddenRequires the full deletion configuration; confirm the rewrite happens before any downstream copies are reviewed
Cancellation periodDelay between accepting a delete request and processing it, giving time to cancel a mistaken requestTeams that want a safety window against an over-broad selectorSet the value in your own configuration and confirm it with your team; a longer window delays removal of the sensitive data
delete_request_storeWhere pending and processed delete requests are recorded for the compactorAny deployment that accepts deletes, since deletion is not possible without itMust be configured explicitly; confirm the store and its durability before relying on deletion for compliance
Stream selectorThe label set that identifies which streams the request applies toNarrow removal when the affected application or host is knownAn imprecise selector can remove more than intended, so test it against a narrow sample first
Time windowStart and end timestamps that bound which entries are deletedRemoving a known incident period after a log exposureEntries outside the window stay in place, so confirm the exposure timestamps from your source systems
Line filterOptional text match applied within the selected streams and windowTargeting a specific secret pattern or identifier across a known periodFilters match on the line content, so variants of a value may be missed; verify with a query before and after
Compactor and TSDB prerequisitesDeletion needs retention_enabled on the compactor and is supported with the TSDB indexConfirm these settings before planning any deletion procedureIf either requirement is missing, deletion is not available and the team needs a configuration change first

Delete requests wait out a cancellation period before the compactor rewrites chunks

The flow starts with an operator or script calling the compactor's delete endpoint through the authenticating reverse proxy, which sits on the trust boundary in front of Loki. The request is stored in the delete request store and held for the cancellation period, during which it can still be cancelled. The compactor then filters matching entries out of chunks in object storage, and queries only stop returning those lines after that pass. Check the store, the compactor settings and the cancellation window before you rely on the result.

Deletion passes the proxy, waits in the store, then rewrites chunks before queries change.

Setting up log entry deletion safely

This sequence prepares a self-hosted Loki cluster so that targeted deletion requests are accepted, stored, held for the cancellation period and applied only where you intend. Each step ends with a check you can run before moving on.

  1. Confirm the Loki version and TSDB index

    Start by confirming that your cluster runs a Loki release that supports log entry deletion and that the streams you need to clean use the TSDB index. Deletion is supported with TSDB, so a cluster still on an older index store needs a planned storage change before deletion can be used. Check the running version against the Loki release notes and inspect your schema_config to confirm the store is tsdb. The step is done when the version and index store are written into your change record and a platform owner has signed off on them.

  2. Enable retention on the compactor

    Deletion requests are processed by the compactor, and the compactor only processes them when retention is enabled. Set retention_enabled to true in the compactor configuration and confirm that the compactor runs as a single instance with the storage and working directory it needs. Retention is disabled by default, so this is a deliberate change that also starts retention rules you may have defined. Confirm the setting is loaded by checking the compactor logs after a restart and reviewing the effective configuration on the compactor endpoint.

  3. Set the tenant deletion mode

    Each tenant has a deletion_mode that controls whether delete requests only filter query results or also remove the data from storage. The default is filter-and-delete. Choose filter-only when you need an immediate read-side hide with the option of keeping the underlying chunks, and filter-and-delete when the data must be physically removed. Set the mode in the per-tenant limits for each tenant that will receive requests. The step is complete when you can read back the configured mode for each tenant and the team agrees which mode applies to which tenant.

  4. Configure the delete request store

    Delete requests must be persisted, so the compactor needs a configured delete_request_store in the same object storage backend used for chunks or another store you have approved. Without it, requests cannot be recorded and processed. Confirm the store location, access permissions for the compactor, and that the store survives a compactor restart. Make sure the storage account used for deletion has write access limited to the compactor, since anyone who can write delete requests can remove log entries. The check is a successful startup of the compactor with the store reported as ready in its logs.

  5. Set the cancellation period

    Each delete request waits for a configurable cancellation period before the compactor acts on it, so that an accidental or mistaken request can be cancelled. Set the period to a value your change process can work within, and record it in the runbook along with the cancel procedure. Ask your platform team to confirm the exact configuration key and default for your Loki version in the official documentation before you set it. The step is done when a test request shows the cancellation window in its status and the team knows how to cancel it.

  6. Test with a non-sensitive stream

    Before you touch production data, run the full flow on a stream that holds only test logs. Ingest a few marked entries with a unique line filter, submit a delete request with a narrow time window and that filter, and confirm it appears in the list of requests with a pending status. Let the cancellation period end and confirm the matching entries are removed from query results and that unrelated entries in the same stream remain. Record the request ID, timings and query results as evidence for your change record.

  7. Confirm pending requests before the period ends

    For a real deletion, submit the request with the narrowest stream selector, time window and line filter you can justify, then list the request while it is still pending to confirm the scope matches what was approved. Check the stream selector and time range against a query that returns the same entries before the cancellation period ends. If the scope is wrong, cancel the request. The step closes when the pending request matches the approved scope and you have a dated record of the check.

Who can delete logs and how requests are controlled

The delete API is powerful because it removes data that other controls cannot bring back. Loki does not authenticate requests itself, so the controls around it are a set of decisions you make and verify before the first request is submitted.

Authenticating reverse proxy in front

Loki has no built-in authentication layer, and its documentation says to run an authenticating reverse proxy such as nginx, HAProxy, OAuth2 Proxy or Pomerium in front of it. Deletion endpoints must sit behind that proxy, not be reachable on the internal network or through a debug port. Check that the proxy blocks the delete paths for every client except the approved operators, and test this from outside the proxy's allowed network.

Loki authentication docs

Tenant isolation through X-Scope-OrgID

When auth_enabled is true, Loki identifies each tenant with the X-Scope-OrgID header on every request. A delete request is scoped to the tenant named in that header, so a mistaken or forged header can target the wrong tenant's data. Confirm that the proxy sets or validates this header from the authenticated identity, so that operators cannot choose a tenant they are not entitled to.

Limiting who can submit requests

Decide which roles may create, cancel and list delete requests, and keep that list short. Log deletion is a privileged action, so separate it from ordinary query access and from the people who run the cluster. Confirm that your identity provider groups map to the proxy rules and that removing a person's access takes effect on the delete path as well as the query path.

Audit trail of requests

Record who submitted each delete request, when, for which tenant, stream selector and time window, and whether it was cancelled. Capture this at the reverse proxy and keep the log outside the Loki cluster so that a deletion cannot erase its own record. Ask your compliance team which retention period and review process apply to this audit log before you rely on it as evidence.

Cancellation window as a control

Deletion runs after a configurable cancellation period, which gives an operator time to stop a request that was submitted in error. Who may cancel, and how quickly someone reviews pending requests, determines whether that window protects you. Confirm the configured period with your own cluster settings and document who watches the queue during it.

Copies in backups and other systems

A delete request removes entries from Loki's stored chunks and index, but it does not reach backups, replicated object store versions, exported files or copies sent to a SIEM or another log platform. Treat those copies as a separate question for your data owner and legal or privacy team. Ask your storage and backup owners how long copies persist and whether they can be purged on the same schedule.

Questions buyers ask about Loki log deletion

Can our own team delete log lines from Loki without a consultant?

Yes, if your team can run the compactor, edit its configuration and call its REST endpoints in a controlled change window. The official documentation describes the required settings and the request flow, so the work itself is not specialized. A consultant adds value when the deletion must be scoped precisely across many streams and tenants, when the change must be evidenced for an audit, or when the team has no one who owns the compactor and object store. Ask whether your engineers have run the compactor before and who will verify the result afterward. DeployOpen plans, implements and documents this kind of work in infrastructure you control, under a written scope.

What makes a Loki log deletion take longer or cost more?

Effort follows the size of the deletion scope, not the amount of data alone. The main drivers are:

  • The number of streams, tenants and label combinations that must be matched exactly.
  • Whether the removal uses only a time window or also a line filter, since filters increase the processing work the compactor performs.
  • The object store layout, including how chunks are organized and whether you have a reliable way to confirm which objects changed.
  • The verification you need, such as proof that queries no longer return the content and that the affected data is gone from storage.

Ask any provider to break its quote down by these items and to state which parts are one-time and which are repeated for each incident.

What do we need to provide before a Loki deletion starts?

You need administrative access to the compactor configuration, the ability to call its deletion endpoints, and read access to the object store and index so the result can be checked. You also need an agreed change window, because the compactor's settings are changed and the process is monitored while requests run. Confirm the current retention settings, the tenant deletion mode and whether a delete request store is already configured, since deletion depends on all three. Identify the exact streams, tenant IDs and time range from the incident, and agree who approves the request. Missing any of these usually delays the work more than the deletion itself.

How long do we wait after requesting a Loki log deletion?

Deletion requests do not run immediately. Loki applies a configurable cancellation period after a request is accepted, and the removal happens only after that period ends. The length is set in your own configuration, so confirm the value in your environment rather than assuming a default. Plan for that waiting time in your incident timeline, and tell stakeholders that data may remain visible until the process completes. If the content is a live secret, rotate the credential immediately instead of waiting for the deletion to finish, because deletion removes the logged copy but does not revoke the exposed value.

Can we undo a Loki deletion during the cancellation period?

A pending request can be cancelled during the cancellation period, which stops it before any data is removed. Once the period ends and the removal runs, the deleted entries cannot be recovered from Loki itself. This is why the request should be reviewed twice, with the stream selectors, time window and any line filter checked against a query that shows exactly what will match. Confirm the cancellation procedure for your Loki version and keep a record of who cancelled or approved the request.

How does log deletion relate to retention and object lifecycle rules?

Retention and deletion solve different problems. Retention, applied by the compactor, removes data older than a configured period across a tenant or stream selector, and it is disabled by default. Deletion removes specific entries you name, and it also requires retention to be enabled on the compactor. Object store lifecycle rules operate on the bucket independently of Loki, so they can remove objects on their own schedule and can make your deletion records inconsistent with what is stored. Review all three together so that the deletion, retention and lifecycle settings do not contradict each other or leave copies you did not intend to keep.

Does log deletion meet our audit or privacy requirements by itself?

Deletion is one control within a broader record-keeping process, and it does not establish compliance on its own. Your auditor will look for evidence that the request was approved, scoped, executed within the defined cancellation period and verified, along with the retention settings in force at the time. Those records must be kept outside the data being removed. DeployOpen prepares systems, controls and evidence for compliance assessments, but independent auditors and certification bodies issue any audit report or attestation. Confirm your specific obligations with your compliance team before defining the procedure.

What DeployOpen delivers for a deletion project

DeployOpen can plan and carry out a log deletion project as a fixed-scope piece of work, starting with a written scope that names the affected streams, the tenants that own them, the time window and any line filter. That scope drives everything else, because a delete request that is too broad removes data nobody meant to remove, and one that is too narrow leaves the sensitive text in place. Before any request is sent, the work confirms which tenant deletion_mode applies, whether the compactor runs with retention_enabled, and which delete_request_store will hold the requests, all inside the client's own cloud accounts, data centers or air-gapped network.

The second part of the work is a tested deletion runbook. It covers how requests are created and reviewed, who approves them, how the cancellation period is used to stop a mistaken request before it runs, and what to do when a request is cancelled or fails. DeployOpen tests the runbook against a non-production tenant first, so the operators who will use it have seen the expected behavior, including that a deletion does not reach data outside the selected stream and window. Ask for the runbook to name the roles that approve and execute each step, since that is the document an auditor will ask to see.

The final part is evidence and verification. DeployOpen collects the deletion requests, their parameters, approvals, timestamps and outcomes into a record that compliance reviewers can read, and it retests the affected queries after deletion completes to confirm the entries are gone. DeployOpen prepares this evidence and the controls behind it, but it does not issue audit reports, attestations or certifications. Independent auditors and certification bodies make those determinations, so confirm early which evidence format your assessor expects.

How DeployOpen scopes and delivers Loki log deletion

DeployOpen treats log deletion as a scoped change to a production logging system, not a one-off command. We agree the streams, time windows and filters in writing, configure the compactor and tenant settings your Loki build needs, and verify that the targeted lines are gone once the cancellation period has passed.

How we scope

  • Confirm which tenants, streams and time windows contain the logged secrets or personal data
  • Check that your Loki runs the TSDB index, since log entry deletion is supported with it
  • Agree in writing whether deletion_mode will be filter-only or filter-and-delete for each tenant
  • Engagements are fixed-scope, with deliverables and timelines agreed before work starts

How we build

  • Enable retention_enabled on the compactor and configure a delete_request_store
  • Set tenant deletion_mode and test delete requests against a non-production tenant first
  • Build and review each delete request, including stream selector, time window and line filter
  • Record the cancellation period you configured so the team knows when deletion takes effect

How we hand over

  • Document the compactor settings, tenant limits and the delete request procedure your team will follow
  • Provide a verification runbook that shows how to confirm targeted lines no longer return in queries
  • Describe how backups, object store copies and downstream exports are handled outside Loki
  • Walk your operations and security teams through the process and the approval steps

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers
  • Retest the deletion setup after Loki upgrades that change compactor or deletion behavior
  • Review future deletion requests against the agreed scope and approval process
  • Confirm the current Loki release and compactor settings with your environment before each change

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.