{
  "run_id": "2026-09-16-r3-firecrawl",
  "round": 2,
  "tool": "firecrawl",
  "mode": "search",
  "tc_id": "TC3",
  "capability": "C1",
  "scenario": "S3",
  "suite_role": "probe",
  "query_text": "In Loki, the log aggregation system from Grafana Labs, which configuration block does retention_enabled have to be set in for old log data to actually be deleted?",
  "restrict_domain": null,
  "restriction_mechanism": null,
  "answer_key": "The compactor block. Verbatim: \"`retention_enabled: true` must be set under the `compactor` block, not just in `limits_config`.\" (FAQ \"Why isn't my log retention policy deleting old data?\", bottom third of the page.)",
  "key_urls": [
    {
      "url": "https://grafana.com/docs/loki/",
      "role": "supports"
    },
    {
      "url": "https://grafana.com/oss/loki/",
      "role": "supports"
    }
  ],
  "pass_criteria": "Results are about Grafana Loki, not Marvel's Loki, AND what came back names the compactor block - not merely the top-of-page description of what Loki is",
  "key_verified_date": "2026-09-09",
  "before_check_rule": null,
  "timestamp_utc": "2026-09-16T08:43:56Z",
  "region": "ap-south-1",
  "status": "ok",
  "graded": null,
  "pass_fail": null,
  "grader_notes": null,
  "latency_ms": 12284.0,
  "http_status": 200,
  "error": null,
  "attempts": 1,
  "credits_reported": 11,
  "tokens_reported": null,
  "results": [
    {
      "rank": 1,
      "url": "https://grafana.com/docs/loki/latest/operations/storage/retention/",
      "title": "Log retention | Grafana Loki documentation",
      "content": "![ObservabilityCON 2025](https://a-us.storyblok.com/f/1022730/280x40/b0872b99f9/grafana-logo-observabilitycon-2025-black.svg/m/)\n\nWatch the keynote again and signup for more on-demand sessions.\n\n\n[Watch keynote](https://grafana.com/events/observabilitycon/?plcmt=obscon2025-post-event-banner)![](https://grafana.com/media/events/grafanacon/2025/icon-close-x.svg)\n\n![ObservabilityCON 2025](https://grafana.com/media/events/obscon/2025/grafana-obscon2025-promo-logo-black.svg)\n\n\ud83d\udce2 Registration + agenda now live\nExplore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).\n\n\n[Register now](https://grafana.com/events/observabilitycon/?tech=target&plcmt=top-banner&aud=default)\n\nSearching...\n\nSite search\n\nAsk Grot AI\n\n[Try using ![Grot AI](https://grafana.com/static/img/grot-chat.svg)**Grot AI** for this query ->](https://grafana.com/grot/?chat=&from=/search)\n\nAll\n\nDocs\n\nView all results\n\nNo results.\n\nThere was an error with your request.\n\n> Documentation for automated readers\n>\n> A curated documentation index is available at: https://grafana.com/llms.txt\n>\n> A complete documentation index is available at: https://grafana.com/llms-full.txt\n>\n> These indexes can help with page discovery before fetching individual documents.\n\nThis page is also available in Markdown, which may be easier for automated readers\nand AI tools to parse than HTML. The Markdown version is available at\nhttps://grafana.com/docs/loki/latest/operations/storage/retention.md, or by sending\nAccept: text/markdown to https://grafana.com/docs/loki/latest/operations/storage/retention/. For broader\ndocumentation discovery, the curated index is available at https://grafana.com/llms.txt\nand the complete index is available at https://grafana.com/llms-full.txt.\n\nLog retention\n\n[Documentation](https://grafana.com/docs/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Grafana Loki](https://grafana.com/docs/loki/latest/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Manage](https://grafana.com/docs/loki/latest/operations/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Storage](https://grafana.com/docs/loki/latest/operations/storage/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)Log retention\n\nOpen source\n\n# Log retention\n\nRetention in Grafana Loki is achieved through the [Compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor).\nBy default the `compactor.retention-enabled` flag is not set, so the logs sent to Loki live forever.\n\n> Note\n>\n> If you have a lifecycle policy configured on the object store, please ensure that it is longer than the retention period.\n\nGranular retention policies to apply retention at per tenant or per stream level are also supported by the Compactor.\n\n> Note\n>\n> The Compactor does not support retention on\n> [legacy index types](https://grafana.com/docs/loki/latest/configure/storage/#index-storage). Please use the\n> [Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/) when using legacy index types.\n> Both the Table manager and legacy index types are deprecated and may be removed in future major versions of Loki.\n\n## Compactor\n\nThe Compactor is responsible for compaction of index files and applying log retention.\n\n> Note\n>\n> Run the Compactor as a singleton (a single instance).\n\nThe Compactor runs compaction and retention on two independent schedules:\n\n- Compaction runs every `compactor.compaction-interval`.\n- Retention runs every `compactor.apply-retention-interval`. If you leave this at its default of `0s`, Loki sets it to the same value as `compactor.compaction-interval`. Whenever the two intervals are equal, Loki extends the retention interval by the smaller of `10m` or half the interval, so that compaction and retention do not run at the same time. For example, with the default `compaction_interval` of `10m`, retention runs every `15m`.\n\nIf the Compactor falls behind on either schedule, it runs the corresponding operation as soon as possible.\nBoth compaction and retention are idempotent, which means once the action has been performed, if the action is performed multiple times, it has no further effect on logs after the first time it is performed. If the Compactor restarts, it continues from where it left off.\n\n> Note\n>\n> Changes to your retention period are not retroactive, that is, they are not applied to logs that have already been ingested.\n\nThe Compactor\u2019s algorithm to apply retention is as follows:\n\n- For each day or table (one table per day with 24h index period):\n  - Compact multiple index files in the table into per-tenant index files. Result of compaction is a single index file per tenant per day.\n  - Traverse the per-tenant index. Use the tenant configuration to identify the chunks that need to be removed.\n  - Remove the references to the matching chunks from the index and add the chunk references to a marker file on disk.\n  - Upload the new modified index files.\n\nChunks are not deleted while applying the retention algorithm on the index. They are deleted asynchronously by a sweeper process\nand this delay can be configured by setting `-compactor.retention-delete-delay`. Marker files are used to keep track of the chunks pending for deletion.\n\nChunks cannot be deleted immediately for the following reasons:\n\n- Index Gateway downloads a copy of the index files to serve queries and refreshes them at a regular interval.\nHaving a delay allows the index gateways to pull the modified index file which would not contain any reference to the chunks marked for deletion.\nWithout the delay, index files (that are stale) on the gateways could refer to already deleted chunks leading to query failures.\n\n- It provides a short window of time in which to cancel chunk deletion in the case of a configuration mistake.\n\n\nBy default, marker files are written to local disk, under `<working_directory>/retention/<object_store_type>_<period_from_date>/markers/`. Marker files should be stored on a persistent disk to ensure that the chunks pending for deletion are processed even if the Compactor process restarts.\n\n> Note\n>\n> Grafana Labs recommends running Compactor as a stateful deployment (StatefulSet when using Kubernetes) with a persistent storage for storing marker files.\n\nAlternatively, you can configure the Compactor to store marker files in object storage instead of local disk, by setting `compactor.deletion-marker-object-store-prefix` (`deletion_marker_object_store_prefix`) to a prefix that ends with `/`. When set, the Compactor writes marker files to the same per-period object store bucket used for chunks, under that prefix. On startup it also copies any existing marker files from local disk to that prefix, then removes the local copies. This lets you run the Compactor without a persistent volume for marker files. Leave this setting empty to keep using local disk.\n\n### Retention Configuration\n\nThis Compactor configuration example activates retention.\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\ncompactor:\n  working_directory: /data/retention\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: gcs\nschema_config:\n  configs:\n    - from: \"2020-07-31\"\n      index:\n        period: 24h\n        prefix: index_\n      object_store: gcs\n      schema: v13\n      store: tsdb\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /data/index\n    cache_location: /data/index_cache\n  gcs:\n    bucket_name: loki\n```\n\n> Note\n>\n> Retention is only available if the index period is 24h. Single store TSDB and single store BoltDB require 24h index period.\n\n`retention_enabled` should be set to true. Without this, the Compactor will only compact tables.\n\n`delete_request_store` should be set to configure the store for delete requests. This is required when retention is enabled.\n\n`working_directory` is the directory where marked chunks and temporary tables will be saved.\n\n`compaction_interval` dictates how often compaction is applied. If the Compactor falls behind, compaction occurs as soon as possible.\n\n`apply_retention_interval` dictates how often retention is applied, independently of `compaction_interval`. Refer to [Compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor) for how the default value is derived from `compaction_interval`.\n\n`retention_delete_delay` is the delay after which the Compactor will delete marked chunks.\n\n`retention_delete_worker_count` specifies the maximum quantity of goroutine workers instantiated to delete chunks.\n\nA few other options are also relevant when tuning retention:\n\n- `retention_table_timeout` bounds how long the Compactor spends applying retention and processing delete requests on any single table. It defaults to `0s`, meaning no timeout. If the work on a table exceeds this timeout, the Compactor logs a warning and stops early rather than failing, and the remaining work is picked up again on a later run.\n- `retention_backoff_config` controls the retry behavior (minimum and maximum backoff, and number of retries) used by the sweeper when it fails to delete a marked chunk.\n- `delete_request_store_key_prefix` sets the path prefix used to store delete requests within `delete_request_store` (default `index/`).\n- `delete_request_store_db_type` sets the type of database used to store delete requests (default `boltdb`).\n\nRefer to the\n[Configuration reference](https://grafana.com/docs/loki/latest/configure/#compactor) for the full list of `compactor` options and their defaults.\n\n#### Configuring the retention period\n\nRetention period is configured within the\n[`limits_config`](https://grafana.com/docs/loki/latest/configure/#limits_config) configuration section.\n\nThere are two ways of setting retention policies:\n\n- `retention_period` which is applied globally for all log streams.\n- `retention_stream` which is only applied to log streams matching the selector.\n\n> Note\n>\n> Each `retention_stream` rule\u2019s `period` must be at least 24h. Loki rejects configuration with a shorter value, both in the global `retention_stream` list and in any per-tenant override. This minimum does not apply to the `retention_period` setting, either globally or per tenant.\n\nThis example configures global retention that applies to all tenants (unless overridden by configuring per-tenant overrides):\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\n...\nlimits_config:\n  retention_period: 744h\n  retention_stream:\n  - selector: '{namespace=\"dev\"}'\n    priority: 1\n    period: 24h\n  per_tenant_override_config: /etc/overrides.yaml\n...\n```\n\n> Note\n>\n> You can only use label matchers in the `selector` field of a `retention_stream` definition. Arbitrary LogQL expressions are not supported.\n\nPer tenant retention can be defined by configuring\n[runtime overrides](https://grafana.com/docs/loki/latest/configure/#runtime-configuration-file). For example:\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\noverrides:\n    \"29\":\n        retention_period: 168h\n        retention_stream:\n        - selector: '{namespace=\"prod\"}'\n          priority: 2\n          period: 336h\n        - selector: '{container=\"loki\"}'\n          priority: 1\n          period: 72h\n    \"30\":\n        retention_stream:\n        - selector: '{container=\"nginx\", level=\"debug\"}'\n          priority: 1\n          period: 24h\n```\n\nRetention period for a given stream is decided based on the first match in this list:\n\n1. If multiple per-tenant `retention_stream` selectors match the stream, retention period with the highest priority is picked.\n2. If multiple global `retention_stream` selectors match the stream, retention period with the highest priority is picked. This value is not considered if per-tenant `retention_stream` is set.\n3. If a per-tenant `retention_period` is specified, it will be applied.\n4. The global `retention_period` will be applied if none of the above match.\n5. If no global `retention_period` is specified, the default value of `0s` is used, which means logs are kept indefinitely.\n\n> Note\n>\n> The larger the priority value, the higher the priority. If two matching `retention_stream` rules have the same priority, Loki applies the shorter (lowest) of the two periods.\n\nStream matching uses the same syntax as Prometheus label matching:\n\n- `=`: Select labels that are exactly equal to the provided string.\n- `!=`: Select labels that are not equal to the provided string.\n- `=~`: Select labels that regex-match the provided string.\n- `!~`: Select labels that do not regex-match the provided string.\n\nThe example configurations defined above will result in the following retention periods:\n\n- For tenant `29`:\n  - Streams that have the namespace label `prod` will have a retention period of `336h` (2 weeks), even if the container label is `loki`, since the priority of the `prod` rule is higher.\n  - Streams that have the container label `loki` but are not in the namespace `prod` will have a `72h` retention period.\n  - For the rest of the streams in this tenant, per-tenant override `retention_period` value of `168h` is applied.\n- For tenant `30`:\n  - Streams that have the label `nginx` and level `debug` will have a retention period of `24h`.\n  - For the rest of the streams in this tenant the global retention period of `744h`, since there is no override specified.\n- All tenants except `29` and `30`:\n  - Streams that have the namespace label `dev` will have a retention period of `24h` hours.\n  - Streams except those with the namespace label `dev` will have the retention period of `744h`.\n\n> Note\n>\n> If you are a Grafana Cloud customer, you can use the [config self-serve API](https://grafana.com/docs/grafana-cloud/send-data/logs/config-self-serve/#configure-retention) to configure your tenant retention.\n\n## Table Manager (deprecated)\n\nRetention through the\n[Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/) is\nachieved by relying on the object store TTL feature, and will work for both\n[boltdb-shipper](https://grafana.com/docs/loki/latest/operations/storage/boltdb-shipper/) store and chunk/index stores.\n\nIn order to enable the retention support, the Table Manager needs to be\nconfigured to enable deletions and a retention period. Please refer to the\n[`table_manager`](https://grafana.com/docs/loki/latest/configure/#table_manager)\nsection of the Loki configuration reference for all available options.\nAlternatively, the `table-manager.retention-period` and\n`table-manager.retention-deletes-enabled` command line flags can be used. The\nprovided retention period needs to be a duration represented as a string that\ncan be parsed using the Prometheus common model [ParseDuration](https://pkg.go.dev/github.com/prometheus/common/model#ParseDuration). Examples: `7d`, `1w`, `168h`.\n\n> Warning\n>\n> The retention period must be a multiple of the index and chunks table\n> `period`, configured in the\n> [`period_config`](https://grafana.com/docs/loki/latest/configure/#period_config) block.\n> See the\n> [Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/#retention) documentation for\n> more information.\n\n> Note\n>\n> To avoid querying of data beyond the retention period,`max_query_lookback` config in\n> [`limits_config`](https://grafana.com/docs/loki/latest/configure/#limits_config) must be set to a value less than or equal to what is set in `table_manager.retention_period`.\n\nWhen using S3 or GCS, the bucket storing the chunks needs to have the expiry\npolicy set correctly. For more details check\n[S3\u2019s documentation](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)\nor\n[GCS\u2019s documentation](https://cloud.google.com/storage/docs/managing-lifecycles).\n\nIf you must delete ingested logs, you can delete old chunks in your object store. Note,\nhowever, that this only deletes the log content and keeps the label index\nintact; you will still be able to see related labels but will be unable to\nretrieve the deleted log content.\n\nFor further details on the Table Manager internals, refer to the\n[Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/) documentation.\n\nAlternatively, if the BoltDB Shipper is configured for the index store, you can enable\n[Log entry deletion](https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/) to delete log entries from a specific stream.\n\n## Example Configuration\n\nExample configuration with GCS with a 28 day retention:\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nschema_config:\n  configs:\n    - from: 2018-04-15\n      store: tsdb\n      object_store: gcs\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /loki/index\n    cache_location: /loki/index_cache\n  gcs:\n    bucket_name: GCS_BUCKET_NAME\n\nlimits_config:\n  max_query_lookback: 672h # 28 days\n  retention_period: 672h   # 28 days\n\ncompactor:\n  working_directory: /data/retention\n  delete_request_store: gcs\n  retention_enabled: true\n```\n\n## Object store lifecycle policies\n\nLoki stores chunks and indexes as objects in the configured object store (S3, GCS, Azure Blob Storage, and so on). Chunks are deleted by the [Compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor) according to your configured retention, but the Compactor only removes chunk objects: it never deletes the objects that hold cluster state, such as the index or the cluster seed.\n\nIf you also configure an object store lifecycle policy on the bucket, scope it carefully. A blanket \u201cdelete everything older than N days\u201d rule will eventually remove objects that Loki must keep, which corrupts the store and causes query failures. The note at the top of this page applies here as well: any lifecycle expiration must be longer than your retention period.\n\n> Warning\n>\n> Never apply a lifecycle rule with an empty prefix (one that targets the whole bucket). Always scope lifecycle rules to the per-tenant chunk prefixes described below.\n\n### Bucket object layout\n\nThe following objects are written to the configured bucket. The exact prefixes depend on your `schema_config` and on whether multi-tenancy is enabled, so confirm them against your own configuration before writing a lifecycle rule.\n\nExpand table\n\n| Object or prefix | Content | Safe to expire with a lifecycle policy? |\n| --- | --- | --- |\n| `<tenant_id>/` (for example, `fake/` in single-tenant mode, or your org ID per tenant) | Chunk objects (the log data). | Yes. These are the only objects a lifecycle rule should target. |\n| Index objects (under the index path prefix, `index/` by default, set by `index.path_prefix` in `schema_config`) | TSDB or BoltDB index files, written by ingesters and rewritten by the Compactor. The `index.prefix` value (for example `index_` or `loki_index_`) is the table-name prefix used inside this path, not the path itself, so match a lifecycle rule against the path prefix. | No. Loki manages the index lifecycle internally. Deleting index objects removes references to live chunks and breaks queries. |\n| `loki_cluster_seed.json` | A small file at the bucket root holding the cluster seed used by usage reporting. It is written once and never rotated. | No. A blanket age-based rule will delete it once it ages past the time to live (TTL). |\n| Delete-request store objects (a `delete_requests/` table under `delete_request_store_key_prefix`, `index/` by default, in the bucket configured by `delete_request_store`) | The Compactor\u2019s database of delete requests submitted through the<br>[Log entry deletion](https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/) API, and their processing status. | No. Removing these makes the Compactor lose track of pending delete requests. |\n| Deletion marker objects (only present if you set `deletion_marker_object_store_prefix`; otherwise markers are kept on the Compactor\u2019s local disk and never appear in the bucket) | The Compactor\u2019s record of chunks that are marked for deletion but not yet swept. Written under the configured prefix in the same per-period bucket used for chunks. | No. Removing these makes the Compactor lose track of chunks pending deletion. |\n| Ruler store objects (if the Ruler is backed by the same bucket) | Recording and alerting rule files. | No. These are configuration, not time-series data. |\n\n### Compactor retention versus object store lifecycle policies\n\nCompactor retention and object store lifecycle policies are two independent mechanisms, and they should not be configured in ways that conflict:\n\n- The Compactor is index-aware. It only deletes a chunk after it has removed every reference to that chunk from the index, and it waits `compactor.retention-delete-delay` (default `2h`) before the sweeper deletes the marked chunk, so that index gateways pick up the rewritten index first.\n- An object store lifecycle policy is index-unaware. It deletes objects purely by age and prefix, with no knowledge of whether a chunk is still referenced by the index.\n\nFor most deployments, enabling Compactor retention is sufficient and an object store lifecycle policy is not required. If you do add a lifecycle policy as a cost safety net, set its expiration **longer** than your retention period plus `compactor.retention-delete-delay`, so the Compactor always deletes chunks first and the lifecycle rule only ever catches objects the Compactor has already orphaned.\n\n### Example: Amazon S3 lifecycle policy\n\nThis policy expires only chunk objects under a single tenant prefix. Replace `fake/` with your tenant prefix (use one rule per tenant, or your org ID prefix, when multi-tenancy is enabled). The `Days` value must be larger than your retention period plus the delete delay.\n\nJSON![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```json\n{\n  \"Rules\": [\\\n    {\\\n      \"ID\": \"loki-chunk-expiration\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"fake/\"\\\n      },\\\n      \"Expiration\": {\\\n        \"Days\": 395\\\n      }\\\n    }\\\n  ]\n}\n```\n\nApply it with the AWS CLI:\n\nBash![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```bash\naws s3api put-bucket-lifecycle-configuration \\\n  --bucket YOUR_LOKI_BUCKET \\\n  --lifecycle-configuration file://lifecycle.json\n```\n\n### Example: Google Cloud Storage lifecycle rule\n\nThe equivalent GCS rule expires objects by age and prefix. As with S3, scope `matchesPrefix` to the tenant chunk prefix and keep `age` larger than your retention period plus the delete delay.\n\nJSON![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```json\n{\n  \"rule\": [\\\n    {\\\n      \"action\": {\"type\": \"Delete\"},\\\n      \"condition\": {\\\n        \"age\": 395,\\\n        \"matchesPrefix\": [\"fake/\"]\\\n      }\\\n    }\\\n  ]\n}\n```\n\nApply it with the Google Cloud CLI:\n\nBash![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```bash\ngcloud storage buckets update gs://YOUR_LOKI_BUCKET --lifecycle-file=lifecycle.json\n```\n\nFor Azure Blob Storage, use a management policy with a `prefixMatch` set to the tenant chunk prefix and the same \u201cexpiration must exceed retention plus delete delay\u201d rule.\n\n## Was this page helpful?\n\n![\ud83d\udc4d](https://grafana.com/media/images/svg/thumbs-up.svg) Yes![\ud83d\udc4e](https://grafana.com/media/images/svg/thumbs-up.svg) No\n\n[Suggest an edit in GitHub](https://github.com/grafana/loki/edit/release-3.7.x/docs/sources/operations/storage/retention.md) [Create a GitHub issue](https://github.com/grafana/loki/issues/new?title=Documentation%20feedback:%20/docs/sources/operations/storage/retention.md) [Email docs@grafana.com](mailto:docs@grafana.com) [Help and support](https://grafana.com/help/) [Community](https://grafana.com/community/)\n\n## Related resources from Grafana Labs\n\nAdditional helpful documentation, links, and articles:\n\n[![webinar icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-webinar.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Getting started with logging and Grafana Loki](https://grafana.com/static/assets/featured/getting-started-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nGetting started with logging and Grafana Loki\\\\\n\\\\\nSee a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.](https://grafana.com/go/webinar/getting-started-with-logging-and-grafana-loki/?pg=docs-loki-latest-operations-storage-retention&plcmt=related) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Essential Grafana Loki configuration settings](https://grafana.com/static/assets/featured/logging-with-loki-essential-configuration-settings_featured.png?w=400)\\\\\n\\\\\nEssential Grafana Loki configuration settings\\\\\n\\\\\nThis webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.](https://grafana.com/go/webinar/logging-with-loki-essential-configuration-settings/?pg=docs-loki-latest-operations-storage-retention&plcmt=related-2) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Scaling and securing your logs with Grafana Loki](https://grafana.com/static/assets/featured/scaling-and-securing-your-logs-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nScaling and securing your logs with Grafana Loki\\\\\n\\\\\nThis webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.](https://grafana.com/go/webinar/scaling-and-securing-your-logs-with-grafana-loki/?pg=docs-loki-latest-operations-storage-retention&plcmt=related-3)\n\nAsk Grafana Assistant",
      "content_chars": 26386,
      "published_date": null
    },
    {
      "rank": 2,
      "url": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
      "title": "Loki does not delete logs after retention delete delay",
      "content": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/8) [Skip to top](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1)\n\n[Skip to main content](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\n- [loki](https://community.grafana.com/tag/loki/14)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n\n[cancel selecting](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n\n4.6k\nviews\n2\nlinks\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/b782af/48.png)3](https://community.grafana.com/u/lquerinmech \"lquerinmech\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/48.png)](https://community.grafana.com/u/etc5678 \"etc5678\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/48.png)](https://community.grafana.com/u/sabirouassim \"sabirouassim\")\n\n[Feb 2023](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1 \"Jump to the first post\")\n\n1 / 8\n\n\nFeb 2023\n\n\n[Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/8)\n\n## post by lquerinmech on Feb 16, 2023\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/b782af/48.png)](https://community.grafana.com/u/lquerinmech)\n\n[lquerinmech](https://community.grafana.com/u/lquerinmech)\n\n[Feb 2023](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898 \"Post date\")\n\nI have loki on my local windows pc i run loki fine and i can store and see logs with grafana, but i am not able to delete logs after a specific amount of time: Is this even a feature of Loki?\n\nFor reference this is my config.yaml\n\n\\`auth\\_enabled: false\n\nserver:\n\nhttp\\_listen\\_port: 3100\n\ngrpc\\_listen\\_port: 9096\n\ncommon:\n\ninstance\\_addr: 127.0.0.1\n\npath\\_prefix: /tmp/loki\n\nstorage:\n\nfilesystem:\n\nchunks\\_directory: /tmp/loki/chunks\n\nrules\\_directory: /tmp/loki/rules\n\nreplication\\_factor: 1\n\nring:\n\nkvstore:\n\nstore: inmemory\n\nquery\\_range:\n\nresults\\_cache:\n\ncache:\n\nembedded\\_cache:\n\nenabled: true\n\nmax\\_size\\_mb: 100\n\ncompactor:\n\nworking\\_directory: /tmp/loki/compactor\n\nretention\\_enabled: true\n\nretention\\_delete\\_delay: 5h\n\n```\n\n  schema_config:\n```\n\nconfigs:\n\n\\- from: 2020-10-24\n\nstore: boltdb-shipper\n\nobject\\_store: filesystem\n\nschema: v11\n\nindex:\n\nprefix: index\\_\n\nperiod: 24h\n\nruler:\n\nalertmanager\\_url: [http://localhost:9093](http://localhost:9093/)``\n\n4.6k\nviews\n2\nlinks\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/b782af/48.png)3](https://community.grafana.com/u/lquerinmech \"lquerinmech\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/48.png)](https://community.grafana.com/u/etc5678 \"etc5678\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/48.png)](https://community.grafana.com/u/sabirouassim \"sabirouassim\")\n\n## post by tonyswumac on Feb 16, 2023\n\n## post by lquerinmech on Feb 17, 2023\n\n## post by etc5678 on Feb 17, 2023\n\n## post by tonyswumac on Feb 17, 2023\n\n## post by lquerinmech on Feb 20, 2023\n\n12 months later\n\n\n## post by sabirouassim on Feb 8, 2024\n\n1 year later\n\n\n## Closed on Feb 7, 2025\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-get-started-dark-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-get-started-dark)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [9](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1) | 10.9k | [Apr 2024](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/11) |\n| [Loki retention isn\u2019t working as expected\u2014logs older than 24 hours are not getting deleted](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [3](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/1) | 549 | [Feb 2025](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/4) |\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |\n| [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14),<br>- [retention](https://community.grafana.com/tag/retention/276) | [5](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1) | 355 | [Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6) |\n| [Logs disappearing after 11 days in storage](https://community.grafana.com/t/logs-disappearing-after-11-days-in-storage/144618)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [14](https://community.grafana.com/t/logs-disappearing-after-11-days-in-storage/144618/1) | 318 | [Dec 2025](https://community.grafana.com/t/logs-disappearing-after-11-days-in-storage/144618/15) |\n\nTopic list, column headers with buttons are sortable.",
      "content_chars": 7260,
      "published_date": null
    },
    {
      "rank": 3,
      "url": "https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/",
      "title": "Log entry deletion | Grafana Loki documentation",
      "content": "![ObservabilityCON 2025](https://a-us.storyblok.com/f/1022730/280x40/b0872b99f9/grafana-logo-observabilitycon-2025-black.svg/m/)\n\nWatch the keynote again and signup for more on-demand sessions.\n\n\n[Watch keynote](https://grafana.com/events/observabilitycon/?plcmt=obscon2025-post-event-banner)![](https://grafana.com/media/events/grafanacon/2025/icon-close-x.svg)\n\n![ObservabilityCON 2025](https://grafana.com/media/events/obscon/2025/grafana-obscon2025-promo-logo-black.svg)\n\n\ud83d\udce2 Registration + agenda now live\nExplore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).\n\n\n[Register now](https://grafana.com/events/observabilitycon/?tech=target&plcmt=top-banner&aud=default)\n\nSearching...\n\nSite search\n\nAsk Grot AI\n\n[Try using ![Grot AI](https://grafana.com/static/img/grot-chat.svg)**Grot AI** for this query ->](https://grafana.com/grot/?chat=&from=/search)\n\nAll\n\nDocs\n\nView all results\n\nNo results.\n\nThere was an error with your request.\n\n> Documentation for automated readers\n>\n> A curated documentation index is available at: https://grafana.com/llms.txt\n>\n> A complete documentation index is available at: https://grafana.com/llms-full.txt\n>\n> These indexes can help with page discovery before fetching individual documents.\n\nThis page is also available in Markdown, which may be easier for automated readers\nand AI tools to parse than HTML. The Markdown version is available at\nhttps://grafana.com/docs/loki/latest/operations/storage/logs-deletion.md, or by sending\nAccept: text/markdown to https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/. For broader\ndocumentation discovery, the curated index is available at https://grafana.com/llms.txt\nand the complete index is available at https://grafana.com/llms-full.txt.\n\nLog entry deletion\n\n[Documentation](https://grafana.com/docs/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Grafana Loki](https://grafana.com/docs/loki/latest/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Manage](https://grafana.com/docs/loki/latest/operations/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Storage](https://grafana.com/docs/loki/latest/operations/storage/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)Log entry deletion\n\nOpen source\n\n# Log entry deletion\n\nGrafana Loki supports the deletion of log entries from a specified stream.\nLog entries that fall within a specified time window and match an optional line filter are those that will be deleted.\n\nLog entry deletion is supported when the TSDB index is configured as the index store. It is also supported on the deprecated BoltDB Shipper index, but BoltDB Shipper is being removed in Loki 4.0, so new deployments should use TSDB.\n\nThe compactor component exposes REST\n[endpoints](https://grafana.com/docs/loki/latest/reference/loki-http-api/#compactor) that process delete requests.\nHitting the endpoint specifies the streams and the time window.\nThe deletion of the log entries takes place after a configurable cancellation time period expires.\n\nLog entry deletion relies on configuration of the custom logs retention workflow as defined for the\n[compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor). The compactor looks at unprocessed requests which are past their cancellation period to decide whether a chunk is to be deleted or not.\n\n## Configuration\n\nEnable log entry deletion by setting `retention_enabled` to `true` in the compactor\u2019s configuration (`-compactor.retention-enabled` on the command line). The tenant\u2019s `deletion_mode` must also be `filter-only` or `filter-and-delete`, which is the case by default.\n`delete_request_store` also needs to be configured when retention is enabled to process delete requests, this determines the storage bucket that stores the delete requests.\n\n> Warning\n>\n> Be very careful when enabling retention. It is strongly recommended that you also enable versioning on your objects in object storage to allow you to recover from accidental misconfiguration of a retention setting. If you want to enable deletion but do not want to enforce retention, configure the `retention_period` setting with a value of `0s`.\n\n`deletion_mode` is a global and per-tenant setting in\n[`limits_config`](https://grafana.com/docs/loki/latest/configure/#limits_config). Its default value is `filter-and-delete`, so log entry deletion is active for every tenant as soon as `retention_enabled` is `true` and `delete_request_store` is configured, unless you explicitly change the mode. Set `deletion_mode` in the main configuration file for a global default, or override it per tenant in the\n[runtime configuration file](https://grafana.com/docs/loki/latest/configure/#runtime-configuration-file).\n\n`deletion_mode` supports three values:\n\n- `disabled`: Deletion is not allowed. Requests to the deletion API endpoints are rejected with a `403 Forbidden` response.\n- `filter-only`: Log lines matching the query in the delete request are filtered out when querying Loki. They are not removed from storage.\n- `filter-and-delete`: Log lines matching the query in the delete request are filtered out when querying Loki, and they are also removed from storage. This is the default.\n\nA delete request may be canceled within a configurable cancellation period. Set the `delete_request_cancel_period` in the compactor\u2019s YAML configuration or on the command line when invoking Loki. Its default value is 24h. To cancel a delete request that has already started processing, pass the `force=true` query parameter to the cancellation endpoint.\n\nDelete requests that include a line filter are split into smaller requests that each cover no more than `delete_max_interval` (24h by default). You can request a smaller split for a single request with the `max_interval` query parameter, but it cannot be larger than `delete_max_interval`. Delete requests without a line filter are not split. Refer to the\n[HTTP API reference](https://grafana.com/docs/loki/latest/reference/loki-http-api/#request-log-deletion) for the full set of request parameters.\n\nDelete requests themselves are stored using the database type set by `delete_request_store_db_type`, which defaults to `boltdb`. You can instead use `sqlite`. When you migrate from one database type to another, you can set `backup_delete_request_store_db_type` to `boltdb` so that delete requests are also written to a backup database. Refer to the\n[compactor configuration reference](https://grafana.com/docs/loki/latest/configure/#compactor) for details.\n\nThe deletion API endpoints are registered only when `compactor.retention_enabled` is `true`. When retention is not enabled, the endpoints are unavailable for every tenant, whatever the `deletion_mode` value is. When retention is enabled, use the `deletion_mode` tenant override to control which tenants can use the deletion API.\n\n> Note\n>\n> Deletion of log lines with line filters is one of the compactor\u2019s most resource-intensive operations. If you delete large volumes of data with line filters, refer to\n> [Horizontal scaling of Compactor](https://grafana.com/docs/loki/latest/operations/storage/compactor-horizontal-scaling/) to distribute that work across multiple compactor instances.\n\n## Was this page helpful?\n\n![\ud83d\udc4d](https://grafana.com/media/images/svg/thumbs-up.svg) Yes![\ud83d\udc4e](https://grafana.com/media/images/svg/thumbs-up.svg) No\n\n[Suggest an edit in GitHub](https://github.com/grafana/loki/edit/release-3.7.x/docs/sources/operations/storage/logs-deletion.md) [Create a GitHub issue](https://github.com/grafana/loki/issues/new?title=Documentation%20feedback:%20/docs/sources/operations/storage/logs-deletion.md) [Email docs@grafana.com](mailto:docs@grafana.com) [Help and support](https://grafana.com/help/) [Community](https://grafana.com/community/)\n\n## Related resources from Grafana Labs\n\nAdditional helpful documentation, links, and articles:\n\n[![webinar icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-webinar.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Getting started with logging and Grafana Loki](https://grafana.com/static/assets/featured/getting-started-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nGetting started with logging and Grafana Loki\\\\\n\\\\\nSee a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.](https://grafana.com/go/webinar/getting-started-with-logging-and-grafana-loki/?pg=docs-loki-latest-operations-storage-logs-deletion&plcmt=related) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Essential Grafana Loki configuration settings](https://grafana.com/static/assets/featured/logging-with-loki-essential-configuration-settings_featured.png?w=400)\\\\\n\\\\\nEssential Grafana Loki configuration settings\\\\\n\\\\\nThis webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.](https://grafana.com/go/webinar/logging-with-loki-essential-configuration-settings/?pg=docs-loki-latest-operations-storage-logs-deletion&plcmt=related-2) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Scaling and securing your logs with Grafana Loki](https://grafana.com/static/assets/featured/scaling-and-securing-your-logs-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nScaling and securing your logs with Grafana Loki\\\\\n\\\\\nThis webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.](https://grafana.com/go/webinar/scaling-and-securing-your-logs-with-grafana-loki/?pg=docs-loki-latest-operations-storage-logs-deletion&plcmt=related-3)\n\nAsk Grafana Assistant",
      "content_chars": 10115,
      "published_date": null
    },
    {
      "rank": 4,
      "url": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
      "title": "Loki log retention policy and period - Grafana community forums",
      "content": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6) [Skip to top](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1)\n\n[Skip to main content](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\n- [loki](https://community.grafana.com/tag/loki/14),\n- [retention](https://community.grafana.com/tag/retention/276)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n\n[cancel selecting](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n\n355\nviews\n1\nlink\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)3](https://community.grafana.com/u/lyncops \"lyncops\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/48.png)](https://community.grafana.com/u/bladeno02 \"bladeno02\")\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1 \"Jump to the first post\")\n\n1 / 6\n\n\nJun 2025\n\n\n[Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6)\n\n## post by lyncops on Jun 27, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)](https://community.grafana.com/u/lyncops)\n\n[lyncops](https://community.grafana.com/u/lyncops)\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531 \"Post date\")\n\nHey Folks,\n\nI have configured a log retention policy in Loki to store logs for 30days, but someway somehow my logs are being kept for only 10 days.\n\nFor instance, today\u2019s date is 2025-06-27 and based on my configured log retention policy, I should be able to query logs as far back as 2025-06-01, but I can only get logs up to 2025-06-17 which seems to me the logs in loki are only retained for 10days.\n\nWhat is the issue here and how can I fix this?\n\nReference doc: [Log retention \\| Grafana Loki documentation](https://grafana.com/docs/loki/latest/operations/storage/retention/#table-manager-deprecated)\n\nThis is my loki retention configuration:\n\n```yaml\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 720h\n\ncompactor:\n  working_directory: /tmp/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n```\n\n355\nviews\n1\nlink\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)3](https://community.grafana.com/u/lyncops \"lyncops\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/48.png)](https://community.grafana.com/u/bladeno02 \"bladeno02\")\n\n## post by tonyswumac on Jun 27, 2025\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)](https://community.grafana.com/u/tonyswumac)\n\n[tonyswumac](https://community.grafana.com/u/tonyswumac)\nGrafana Champion\n\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/2 \"Post date\")\n\n1. Can you share your entire configuration, please?\n2. Do you see logs from compactor that it\u2019s actually deleting chunk files?\n3. Since you are using filesystem, do you have any local filesystem clean up process?\n\n## post by lyncops on Jun 28, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)](https://community.grafana.com/u/lyncops)\n\n[lyncops](https://community.grafana.com/u/lyncops)\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/3 \"Post date\")\n\nThis is my entire configuration\n\n```yaml\n\nauth_enabled: false\n\nserver:\n  http_listen_port: <port>\n  grpc_listen_port: <port>\n  log_level: info\n  grpc_server_max_concurrent_streams: 1000\n\ncommon:\n  instance_addr: <localhost>\n  path_prefix: /tmp/loki\n  storage:\n    filesystem:\n      chunks_directory: /tmp/loki/chunks\n      rules_directory: /tmp/loki/rules\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nquery_range:\n  results_cache:\n    cache:\n      embedded_cache:\n        enabled: true\n        max_size_mb: 100\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 720h\n\ncompactor:\n  working_directory: /tmp/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n\npattern_ingester:\n  enabled: true\n  metric_aggregation:\n    loki_address: localhost:<port>\n\nruler:\n  alertmanager_url: http://localhost:<port>\n\nfrontend:\n  encoding: protobuf\n\n# querier:\n#   engine:\n#     enable_multi_variant_queries: true\n\n# Optional: disable anonymous reporting\n# analytics:\n#   reporting_enabled: false\n```\n\nIn my compactor, I see some delete items in the directory, the content in the \u201cdeletion\u201d file is binary so i\u2019m not sure if the deletion is actually happening\n\n```csharp\n\n[root@ip-10-0-0-41 compactor]# du -sh *\n0\tdelete_requests\n16K\tdeletion\n0\tretention\n```\n\nAnd to answer your third question, I do not have any local filesystem clean up process\n\n## post by tonyswumac on Jun 30, 2025\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)](https://community.grafana.com/u/tonyswumac)\n\n[tonyswumac](https://community.grafana.com/u/tonyswumac)\nGrafana Champion\n\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/4 \"Post date\")\n\nI would advise you first to change your chunks and rules directories to something other than `/tmp`.\n\n## post by lyncops on Jun 30, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)](https://community.grafana.com/u/lyncops)\n\n[lyncops](https://community.grafana.com/u/lyncops)\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/5 \"Post date\")\n\nI have updated the chunk and rules directory to `/etc/loki` and also changed the retention policy to 3 days so that it can be easily verified if there have been any change. I will keep this thread updated of the results after 5 days (on Friday).\n\nThis is my current configuration:\n\n```yaml\n\nauth_enabled: false\n\nserver:\n  http_listen_port: <port>\n  grpc_listen_port: <port>\n  log_level: info\n  grpc_server_max_concurrent_streams: 1000\n\ncommon:\n  instance_addr: <localhost>\n  path_prefix: /etc/loki\n  storage:\n    filesystem:\n      chunks_directory: /etc/loki/chunks\n      rules_directory: /etc/loki/rules\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nquery_range:\n  results_cache:\n    cache:\n      embedded_cache:\n        enabled: true\n        max_size_mb: 100\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 72h\n\ncompactor:\n  working_directory: /etc/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n\npattern_ingester:\n  enabled: true\n  metric_aggregation:\n    loki_address: localhost:<port>\n\nruler:\n  alertmanager_url: http://localhost:<port>\n\nfrontend:\n  encoding: protobuf\n\n# querier:\n#   engine:\n#     enable_multi_variant_queries: true\n\n# Optional: disable anonymous reporting\n# analytics:\n#   reporting_enabled: false\n```\n\n5 months later\n\n\n## post by bladeno02 on Dec 3, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/48.png)](https://community.grafana.com/u/bladeno02)\n\n[bladeno02](https://community.grafana.com/u/bladeno02)\n\n[Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6 \"Post date\")\n\nany update here, i have similar issue ,index file have 30d retention but chunk data only 10d ??\n\ni using helm loki 6.29\n\nmc find myminio/chunks/fake --older-than=\u201c9d6h\u201d \\|wc -l\n\n137\n\nbash-5.1$ mc find myminio/chunks/fake --older-than=\u201c10d\u201d \\|wc -l\n\n0\n\nbash-5.1$ mc ilm ls myminio/chunks\n\nmc: Unable to get lifecycle. The lifecycle configuration does not exist.\n\nThank !\n\n### This topic will close a year after the last reply.\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-obs-stack-light-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-obs-stack-light)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [9](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1) | 10.9k | [Apr 2024](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/11) |\n| [Log retention in Loki is not working / Query rollback is not changeing as well](https://community.grafana.com/t/log-retention-in-loki-is-not-working-query-rollback-is-not-changeing-as-well/122207)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [3](https://community.grafana.com/t/log-retention-in-loki-is-not-working-query-rollback-is-not-changeing-as-well/122207/1) | 385 | [May 2024](https://community.grafana.com/t/log-retention-in-loki-is-not-working-query-rollback-is-not-changeing-as-well/122207/4) |\n| [Loki retention isn\u2019t working as expected\u2014logs older than 24 hours are not getting deleted](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [3](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/1) | 549 | [Feb 2025](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/4) |\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |\n| [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1) | 4.6k | [Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/7) |\n\nTopic list, column headers with buttons are sortable.",
      "content_chars": 12750,
      "published_date": null
    },
    {
      "rank": 5,
      "url": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
      "title": "Meet Grafana LOKI, a Log Aggregation System for ... - YouTube",
      "content": "![Thumbnail (1920x1080)](https://i.ytimg.com/vi/h_GGd7HfKQ8/maxresdefault.jpg)\n# [Meet Grafana LOKI, a Log Aggregation System for EVERYTHING](https://www.youtube.com/watch?v=h_GGd7HfKQ8)\n\n**Visibility**: Public\n**Uploaded by**: [Techno Tim](https://www.youtube.com/@TechnoTim)\n**Uploaded at**: 2021-11-20\n**Published at**: \n**Length**: 28:13\n**Views**: 297254\n**Likes**: 7589\n**Category**: Science & Technology\n\n## Description\n\n```\nI've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I've decided to switch.  I've switched to Grafana Loki for all of my logs for all of my systems - this includes machines, devices, docker systems and hosts, and my all of my Kubernetes clusters.  If you're thinking of using Grafana and are also looking for a fast way to log all of your systems, join me as we discuss and configure Grafana Loki.\n\nVideo Notes: https://technotim.live/posts/grafana-loki/\n\nDon't want to host it yourself?  Check out Grafana Cloud and sign up for a free account https://l.technotim.live/grafana-labs\n\nSupport me on Patreon: https://www.patreon.com/technotim\nSponsor me on GitHub: https://github.com/sponsors/timothystewart6\nSubscribe on Twitch: https://www.twitch.tv/technotim\nBecome a YouTube member: https://www.youtube.com/channel/UCOk-gHyjcWZNj3Br4oxwh0A/join\nMerch Shop \ud83d\udecd\ufe0f: https://l.technotim.live/shop\nGear Recommendations: https://l.technotim.live/gear\nGet Help in Our Discord Community: https://l.technotim.live/discord\n2nd channel: https://www.youtube.com/@TechnoTimTalks\n\n(Affiliate links may be included in this description. I may receive a small commission at no cost to you.)\n\n00:00 - Intro\n00:59 - How does Gafana Loki work?\n01:39 - What are we going to configure today?\n02:41 - What are the requirements?\n02:58 - Docker Compose Grafana Loki config\n07:48 - Loki Config\n08:35 - Promtail Config\n10:12 - Start our Loki Stack\n10:49 - How to check if it's working\n11:29 - Logging in to Grafana\n11:55 - Add Loki data source to Grafana\n12:30 - Querying Logs with Grafana and Loki\n15:03 - Configuring Promtail for Docker container logs to Loki\n16:50 - Adding the Grafana Loki Docker driver\n17:37 - Configuring the Docker daemon.json\n19:36 - Recreating Docker containers after applying\n20:37 - Querying Grafana Loki by Docker container labels and streams\n23:07 - Setting up Grafana to be a syslog receiver / endpoint\n24:44 - Setting up a kubernetes cluster with Promtail, Grafana, and Loki\n27:13 - Grafana Loki Dashboards\n27:35 - Which logging system do you use?\n27:51 - Stream Highlight - \"You guys are going to blow up my Raspberry Pi\"\"\n#Grafana #Loki #TechnoTim\n\n\"Violet Haze\" is from Harris Heller's album Bounce.\nhttps://l.technotim.live/sb-music-license\n\nThank you for watching!\n```\n\n## Transcript\n\nover the last couple of weeks i've been\nlooking for a better logging system i've\nused many different logging systems\neither at work or at home in my home lab\nand having a mix of virtual machines\nother devices containers custom code has\nmade it a little bit challenging to find\nthe right one and while i thought my\nlast logging system was the one i was\ngoing to settle on i decided to move to\nsomething else so i've recently switched\nover to grafana loki grafana loki is a\nscalable highly available multi-tenant\nlog aggregation system like prometheus\nit's designed to be cost-effective and\nvery easy to operate so there are a lot\nof similarities between loki and\nprometheus and that's why it's been\ncoined prometheus but for logs one thing\nthey share and one thing that's really\nawesome is that they both use grafana\nnow grafana is a way to query and\nvisualize almost anything which seems\nlike a great fit for logs as well so if\nyou're already using grafana or\ninvestigating it loki will fit right in\nso how does this work well there are\nthree parts really to grifana loki first\nthere's the agent the agent's name is\nprom tail and prom tail works in a push\nconfiguration and not a pole\nconfiguration so that means the agent is\ngoing to push logs into loki rather than\nquery devices and pull it and so this\none or many agents which is pushing logs\nwill push them into loki itself and loki\nis where all of these are stored but\nonce your logs and data is inside of\nloki you can then use grafana to get it\nout to query it and to visualize it i\nknow this might sound a little\ncomplicated and hard to set up but\nactually it's surprisingly easy so\nthat's what we're going to cover today\nso first we'll configure loki and get it\nup and running so we can accept some\nlogs then we'll install our agent prom\ntail so we can push logs into loki and\nthen we'll get grafana up and running\nand we'll configure the loki plugins so\nwe can start querying logs and after we\nget all this working we'll explore a few\ndifferent ways to get logs into our\nsystem we'll talk about scraping logs\nfrom a machine and then we'll talk about\nscraping logs from a docker host which\nis really awesome because all you have\nto do is set it up once and you can\ncollect all the logs from all of the\ncontainers running on that machine and\nit only takes a small amount of config\nand then we'll touch briefly on how to\nset up a syslog endpoint so you can send\nlogs from any device that supports this\nlog and then we'll also touch on how to\nsend logs from a whole entire kubernetes\ncluster but i'll go easy on the\nkubernetes i don't want you to fall\nasleep and if any of that sounds good to\nyou don't forget to give this video a\nthumbs up and subscribe if you haven't\nalready and like all of my videos i'll\nhave a link in the description to my\ndocumentation site where you can copy\nand paste all of this config so what do\nyou need to get started really you just\nneed a machine that can run docker that\ncan be a windows pc or a mac or a server\nor even a raspberry pi any of these are\nfine to run docker to be able to spin\nthese containers up and if you need help\nsetting up docker or docker compose\nthat's also in my documentation so once\nyou have daca running you'll just want\nto make sure it's working by running\ndocker dash v\nsee that you're good next make sure\nyou're inside of a directory\ni don't know where else you would be but\njust make sure you're in the right one\nso we're going to create three\ndirectories one for each of our\ncontainers\nso first we're going to do a mkdir prom\ntail and that's our agent for our logs\nthen we'll make a directory for loki\nthen we'll make a directory for grafana\nnext we'll want to create a docker\ncompose file for all three of these\nservices so we'll do a touch\ndocker-compose.yml for yaml and then we\ncan edit this file so what goes in the\nfile inside of the file goes our loki\nstack so now when i say loki stack i'm\nreferring to prom tail loki and grafana\nand here's the configuration that we're\ngoing to use so let's talk about it real\nquick so this is a typical docker\ncompose file we're going to use docker\ncomposes api's version of three then\nwe're going to create a network called\nloki now this is important because all\nthree of these containers inside of the\nstack are going to share this network\nname so the first service is called loki\nand the image we're going to use is\ngrafana loki and then we're pinning it\nto the latest version then we're going\nto create a volume for it so this volume\ncan be anywhere on this machine that\nyou're on but i'm saying that mine is in\nhome slash server admin slash docker\nvolume slash loki and then we're mapping\nthat to the inside of that container\nthat runs\nat c loki then we're exposing some ports\n3100 on the outside 3100 on the inside\nand then we're saying restart unless\nstopped and this helps if the container\nstarts crashing next is a command when\nthis container starts up and we're\nsaying dash config.file equals etsy loki\nloki dash config.yml now this is our\nlocan config and we'll have this in a\nminute but if you notice this is going\nto map to the inside of slash loki here\nand that mounts to the host so that's\nwhy we're going to put a config file\nthere here in a little bit but i'll show\nyou that here in a second and we're\nsaying hey this container belongs to\nthis network called loki the next\nservice in our stack is promtail now\nremember this is our logging agent so\nhere we're saying use the image grafana\nprom tail and then a version and we're\npinning it to that version then we're\nmounting a few volumes here so we're\nmounting bar log from our machine to var\nlog within that container and then we're\nmounting slash home server admin\ndocker volume slash prom tail on this\nmachine to the containers at c slash\nprom tail and this is just for some\npersistence here and again we're saying\nrestart unless dot and then again we're\nusing the command of dash config file\nequals etsy prom tail prom tail dash\nconfig so same idea as griffon at loki\nup there we're going to specify a config\nfile for this to use so when it mounts\nup and runs this command it can use that\nconfig file at runtime i'll show you\nthat here in a minute next is grafana so\nthis is actually going to spin up\ngrafana this one we are pinning the\nlatest because that's what grafana says\nto do next we're setting a user of 1000.\nnow this helps with permission on the\nvolume that grafana needs to write to\nnow the way you can find this is just\nrunning id and you can see your id right\nhere the uid of a thousand again that\nmight be different from you but take\nthat volume and plug it into the config\nthen speaking of volumes and persistence\nthis is where our volume is going to be\nstored for grafana so on the outside or\nthe host it's server admin slash docker\nvolumes slash grafana and then on the\ninside it's var\nlib slash grafana so this will persist\ngrafana itself so that every time you\nreboot the container you don't lose your\nconfiguration for grafana and next is\nports of 3000 on the outside and 3000 on\nthe inside now i have a quick comment\nhere that says you might need to change\nthis and this applies to every port 3000\nis a pretty common port so is 3100 so if\nyou need to change those you would\nchange it on the outside here on the\nleft side this is the one that's exposed\non your container and 3000 is a very\ncommon port for me because i run a lot\nof node stuff and they all use 3000 so i\nhad a comment here specifically for\nmyself but this applies to every port\nyou see in the configuration here\nremember change the left side left side\nis your configuration right side is the\ncontainers configuration which you can't\nchange unless you rebuild the container\nand then we see restart unless stopped\nagain and then networks loki so this\nties them all together so they're all\nusing the loki network so they can all\ncommunicate to each other within this\nstack so let's take this configuration\nhere\nand we'll copy it and we'll go back into\nour server for this docker compose file\nand we'll paste our configuration in\nthere then we'll save it then if you do\nan ls you should see your folders there\nnow you see a couple other folders that\ni have there but you should see grafana\nloki and prom tail there and then our\ndocker compose file that we created but\nbefore we start it up we need a couple\nadditional configs remember i mentioned\nearlier we need config for prom tail and\nwe need config for loki and that's\nspecified here so let's look at a file\ncalled\nloki-config.yaml here's your\nconfiguration for loki a hundred percent\nof this is the default setting that they\nsay to use for loki it has some\nconfigurations for servers ports some\npaths within the container schema config\nand a whole bunch of other configuration\nnow you shouldn't need to change\nanything in here unless you have a\nspecialized setup or specialized needs\nfor other systems that you're running so\nlet's copy this configuration and then\ngo inside of our loki folder and create\na\nloki-config.yaml file\nonce we create it then we can edit it\nand we're going to paste that\nconfiguration into there so let's save\nthat and close and now we'll need to do\nthe same thing for prom tail\nlet's go one folder up\nthen go into prom tail\nand let's do a touch\ntom tail dash config\ndot dml\nthen we can edit it\nand here is our prom tail config and\nremember prom tail is our agent to\nscrape logs so if we look here some more\nconfiguration for the server what port\nit's listening on a positions key that\npoints to a file name that points to a\nyaml file within the container then\nwe'll have a client's url with loki at\n3100\nloki slash api slash v1 slash push so\nthis is the endpoint where it's going to\npush logs and it could refer to it by\nloki because it's within this stack and\nwe can refer to it by name and then we\nhave some configuration for how to\nscrape logs now this should be a common\nbut local machine logs we're going to\nconfigure first so we're going to scrape\nlogs from this local machine and then\npush them into loki and it's saying the\ntarget is localhost and the job is\ncalled var logs and the path to var log\nand take all logs within var log and\nthen some additional configuration\ncommented out here that we'll talk about\nhere in a little bit\nso let's copy this\npaste it into prom tail dash config\nand let's save it and if we do an ls\nwithin prom tail we should see our prom\ntail config\nand if we go up into loki do the same\nthing we should see our loki dash config\nif we go up into grafana\nand look in there we shouldn't see\nanything so let's go up one more level\nand now we should see our docker compose\nfile that we created so now let's spin\nthis whole entire stack up the way i\ntypically do it is docker dash compose\nup dash d dash dash force recreate\nthere's a million ways you can do it\nthat's the way i do it here so if we run\nthis command this will now create our\nwhole entire stack so hold down loki\npulling down prom tail\nand it's pulling down grafana\nnow it's creating those containers\ndone done done so it looks like we're\nrunning if we do a docker bs really\nquick just to make sure we should see\nall three of these running so prom tail\nstarted 10 seconds ago loki started 10\nseconds ago and grafana started 10\nseconds ago so we're looking good so how\ndo we know it's working well we go to\nthe ip address of this server and we can\ngo to port 3100\nmetrics and you can see here i have some\nmetrics already you can also go to slash\nready to see if it's ready now obviously\nit should say ready if it's ready if it\ndoesn't say ready it'll usually say it's\nwaiting 15 seconds and checking the\ningester again so just keep refreshing\nthis page so this is a good sign our\ngesture is ready and we are getting\nmetrics as shown in this endpoint so now\nwe can actually log in to grafana so how\ndo we do that well it's just port 3000\nso 3000 is where grafana lives so if you\nhaven't logged into grafana before the\nusername and password is admin\nthen you'll be prompted to create a new\npassword and then once you sign in you\nhave grafana so if you're not familiar\nwith grafana this really isn't the\ntutorial for grafana i might have one in\nthe future but you get a platform for\nvisualizing logs metrics or really any\ndata but we can also query that data and\nthat's exactly what we're going to do\nwith our loki stack so the first thing\nwe need to do is actually set up our\ndata source for loki so that we can\nquery the logs\nso let's go into settings here then\nlet's click add data source and we\nshould see\nloki down here so let's select loki and\nin here very little configuration but\nthe url of our endpoint to query now\nit's suggesting http logo host 3100 but\nif you remember in our configuration\nit's an http loki 3100 and we think\neither will work but i think they\nrecommend to use loki and once we have\nthat filled in we can actually save and\ntest so now our data source is connected\nand labels are found so that's good so\nnow let's explore this data our query\nour data in here so let's go to explore\nand you want to make sure that your data\nsource is set to loki here now\nhow do we query now\nteaching you log ql which is the log\nquery language for grafana is kind of\nout of scope for this tutorial but i\nwill give you some examples on how to\nquery data and it's really\nstraightforward at least for the simple\nqueries because they suggest labels for\nyou you get kind of intellisense so\nfirst we'll start with the curly bracket\nand right away it's saying file name or\njob so these are tags from prom tail\nthat it's sending into loki\nand now loki and grafana are recognizing\nthat so let's say job let's choose job\nwhat job did we have for our logs and\nvar logs was in our prom tail\nconfiguration\nand then if we hit enter don't just hit\nenter but hit ctrl enter\nthe enter is going to create a line\nbreak but just hit ctrl enter and right\naway we can query so these are the logs\ncoming from this machine right here var\nlogs we got logs from this machine doing\nalmost nothing at all and so you can see\nall kinds of logs in here so you can see\njuno kernels juno is the name of this\nmachine you can see there looks like\nsome info messages here some warning\nmessages here and a lot of logs that may\nor may not make sense to you depending\non the type of logging you're used to\nlooking at you can actually see one here\nthere's an error here and so we can\nsearch for strings within here too but\nyou'll always have to remember that you\nhave to select first by a tag so i think\nthe way that we search these logs for a\nloose string is the intuitive\npipe equals and then a string in quotes\nso i see down there lots of juno's but i\nsee\ndocker let's search everything within\nhere for docker\nand here we go so we just filter this\nnow to docker you can see how fast we\ncan query through these logs we can\ndrill into these logs look at additional\nmetadata we can include in our filter\nor exclude from our filter oh we just\nfiltered out this entire log that we're\nin\nso we don't want to say not job\nthere we go now if you're interested in\ndoing some more advanced querying i\nhighly recommend checking out their log\nql syntax but really it's not that\ncomplex for me most of the time i'm\nlooking for a needle in the haystack i'm\nlooking for a specific phrase or\nkeywords within my logs and then i'm\nable to narrow down and figure out maybe\nwhat the problem is so this is cool but\nthis is only for this machine's logs\nwhich may or may not be helpful if you\nremember in prom tail we had some\nadditional configuration commented out\nthat was configuration for our docker\ncontainers this is where it gets really\ncool because currently the way that you\ncheck for docker logs is you do docker\nlogs then choose your container\nwe want to say heimdall we say docker\nlogs heimdall we don't see any errors\nthere so then we see docker logs and\nlet's choose another one you can choose\npoor tanner\nsee some errors or some logs there\nand then we can do docker logs up\ntankuma check out uptime kuma and it has\nlots of errors this isn't efficient or\nfun so to make this more fun and more\nefficient we can actually configure prom\ntail to log all of the standard out all\nof these logs that we see here\nto loki and one piece of configuration\nsuper cool so let's go back into prom\ntail\nand let's edit this config now i'll\nbring this up in vs code so you can see\na little bit better but instead of\nscraping logs from the machine let's\nactually now scrape logs from docker so\nthis is saying hey the job name is\ncalled docker there's a pipeline stage\ncalled docker\nand then we're going to create a label\ncall docker and then we're going to grab\nall the logs from docker slash\ncontainers and then everything within\nhere every subfolder that has the file\nname of dash json.log so this does exist\nbut we need to make one more\nconfiguration but let's get this in\nplace first\nso let's copy this let's get rid of our\nprom tail config or we could have\nuncommented that out and let's update it\nwith our docker locks and we'll get rid\nof the host machine logs arguably you\ncan keep them there totally up to you\nbut let's save this close out of here so\nin order to log all of our containers\nlogs to loki we actually need to install\na docker driver or a plug-in for docker\nso that we can push all of those logs to\nloki and so there is a plug-in to do\nthis and it's actually really cool and\nsuper simple to spin up so to do it we\nneed to install the grafana loki docker\ndriver client and to do that it's just\nas simple as running this command right\nhere so docker plug-in install grafana\nloki docker driver latest so this is the\ncontainer alias is loki and grant all\npermissions i know that sounds scary but\nthat's how we get access to all of these\nlogs to send them into loki so let's\ngrab this go back into our machine and\nthen let's run this so this pulled down\nthe container and configured the driver\nfor us there's one more thing we'll need\nto do first just check to make sure it's\ninstalled so docker plug-ins ls and we\nshould see loki here so the loki logging\ndriver and enabled is true next if we go\nback to where we configured the driver\nit mentions in here we need to change a\ncouple of things so we're gonna have to\nconfigure the daemon config the\ndaemon.json located in etsy docker on\nthis machine so we can configure it in\ntwo ways there's a shorthand version and\nthen there's the configuration with some\nadditional options so there's the loki\nserver and then there's the loki batch\nsize so how big is the batch of logs to\npush and then for our configuration for\nour daemon.json for docker it's going to\nbe log driver is loki log options and\nthen inside of this object we have a\nproperty loki url which is the url of\nour server that we're on and here we can\nrefer to it as localhost so you should\nbe able to copy and paste this no\nproblem\nand then the batch size of 400 again\nlet's copy this and remember it said\nthat we need to update the\ndocker'sdaemon.js\nand etsy docker\nso on our server or machine we should be\nable to edit etsc docker\ndaemon.json\nnow this file may or may not exist so\nyou'll just want to edit it and if it's\nnot there it'll create it and here we're\ngoing to paste our options\nsay this then it says after changing\nthis file we'll need to restart the\ndocker daemon for the changes to take\neffect all newly created containers from\nthe host will then send logs to loki via\nthe driver so keep that in mind newly\ncreated so we have some containers\nrunning so we might have to recreate\nthem but that's super easy with a\ncommand but the most important piece\nhere is that we need to restart the\ndocker daemon so we should be able to\nrun sudo system ctl restart you should\nbe able to choose docker\nokay it looks like it restarted docker\ndocker dash v just to make sure it's\nrunning and it is okay so let's go back\nto grafana now really quick so if we go\nback to grafana refresh to make sure\nit's working and make sure you're in\nexplorer\ngo back into our queries we don't see\nadditional labels yet so we should have\none here called docker and containers\nand a whole bunch but remember i said in\nthe documentation it said only for newly\ncreated containers so let's actually\nrecreate our containers that we're\nrunning so in order to recreate these at\nleast for me i have all of my docker\ncompose files within a folder\nso if i go into heimdall i should have\nmy docker compose file and i can run\ndocker\ndash compose horse recreate\nso recreate my heindall container\nand let's do the same for my uptime kuma\nand let's do the same for file browser\nand that should be good so let's do a\ndocker ps to see what's running i have\ncontainers running i see that some are\nrecreated and restarted so now let's go\nback in grafana\nwe go back to grafana and we go into our\nquery\nwhen we do a curly bracket now we see\nsome additional labels so this is really\ncool so we can say container name equals\nand it will suggest one so container\nname equals heimdall\nand\ncontrol enter\nand we can see the logs from heindel\nright here so this just happened really\ncool really cool okay so let's go back\nand if you hit control space at any time\nyou'll get intellisense or suggestions\njust like you would in any ide or vs\ncode\nlet's choose file browser hit enter\ncontrol enter\ni am hitting ctrl enter but control is\nbroken on my keyboard i need a new\nkeyboard\nkeep telling myself that but ctrl enter\nthe other control enter and we can see\nour logs from file browser awesome i\nhave an error here but that's expected\nthat was from my demo and then if we\nlook and what was the last one uptime\nkuma let's see how he's doing control\nenter and we can see our logs here\nreally cool and you can actually combine\nthese logs too if you want to say\nuptight kuma and this doesn't make a\nwhole bunch of sense but the host is\njuno which it is you can hit enter so if\nyou were\ngathering logs from multiple docker\nhosts where they both had uptime kuma\ncontainer names this would filter on\njuno\nwhich i only have one server running but\nif i hit filter on tests this will\nprobably throw an error because i don't\nhave one called test\nbut again if i wanted to search for\nuptime kuma\nsearch and then if we wanted to do the\npipe equals the most intuitive thing\nuh let's see uh k3s\nand enter now we just filtered all of\nour logs for the container name optim\nkuma that contain k3s in there so pretty\npretty awesome pretty powerful stuff and\nso if you have 20 30 10 to however many\ncontainers running now all of those logs\nwill be\ncaptured inside of loki just by editing\nthe daemon jason and then having a\nconfig within prom tail it's a lot of\nwords i know but it'll make sense i\npromise now if you wanted to save this\nquery say in your favorites you could\nyou could bookmark this or you could\njust go into query history look at the\nlast query we just ran\nand then start and then to get back\nlet's say that was closed go into query\nhistory go into star and then you can\nrun this query and the really cool thing\nabout this is it fits within your\necosystem if you're already using\ngrafana so a couple more things i\nmentioned i'll touch on real quick\nassist logging so you can actually set\nthis up to be a syslog target for any of\nyour devices so let's say you're running\nsystems that aren't containers let's say\nyour network firewall or your virtual\nmachine or your windows machine or your\nraspberry pi and you want to pipe those\nlogs into loki as well well you would\njust set up prom tail to host a\nsyslogging endpoint and so to set it up\nas a logging endpoint or a syslog\nreceiver we would add this configuration\nright here so this configuration would\nactually go into prom tail i'll put it\nin there because it'll make a little\nmore sense but if we were to add it to\nour prom tail configuration\nwe could add it here and you could\nobviously comment this out or you can\nadd two jobs but you can have multiple\njobs i just commented these out but by\nadding this configuration we have a job\nnow called syslog it's gonna listen on\n0.0.0.0\non port 1514 and listen for syslogs to\ncome in and so if you enable this then\nyou're able to receive syslogs from any\nmachine now a word of advice should\neither format those syslogs going out or\nformat them before they come into here\nnow it's not a big deal most of the time\nthey'll look pretty good but depending\non your device and how it formats\nsyslogs you might not see them in the\nway you would expect to see them within\ngrafana and another thing before i\nforget because i just noticed this port\n1514 they'll have to open up on your\nprom tail docker convict but if you need\nhelp with configuring that leave a\ncomment below and we'll try to work\nthrough it but that should be all you\nneed to do so the last thing i mentioned\nwas kubernetes not going to spend a ton\nof time on it but you can apply the same\nidea that we applied to docker to\nkubernetes so just think about it in\nkubernetes you have many containers\nrunning many pods running and you want\nto get all of those logs inside of loki\nwell you have a couple of options one\nyou can spin up prom tail there and dump\nall of those logs into this container or\nyou could run your whole entire loki\nstack in kubernetes which is super easy\nthere's a simple helm command you can do\nto run it and i'll actually have a blog\npost article in the documentation below\nof how to do it in kubernetes and\nliterally it took me 10 minutes to get\nrunning if that a lot faster than the\ndocker version because most of it's\npre-configured with helm helm's just a\npackage manager for kubernetes but\nanyways once you get all of your\ncontainers dumping their standard out\nand standard air into loki it's really\npowerful so here's my own home\nproduction version of loki that's\nactually running in kubernetes and it's\nscraping all of the logs from my\nkubernetes containers and dumping them\ninto loki kind of inception but it works\ngreat so right away if i do curly\nbracket you can see i have lots of\nlabels so these are labels that are\nspecific to kubernetes that it already\nhas and discovered\nyou can see i can type in container name\nequals and i can see\nall of my containers that match this\nquery then i can query this container\nand look at them so not much different\nfrom the docker version or any other\nversion but i get all of these labels\nautomatically as these logs come in\nso i could say the app kubernetes io\ninstance is loki and see the logs for\nloki or i can say the chart is\nprometheus\nand look at the logs for that there's no\nlogs there it's a weird label but you\nget the idea or i can say the specific\npod name you can see my pods if i had\nmultiple pods running is\nmy technotem little link server you can\nsee them here and so you can see how\npowerful this is i can log physical\nmachines network devices docker\ncontainers kubernetes clusters really\nanything really fast and the nice part\nabout it is it fits right into the\ngrafana ecosystem it's always been\ncompared to prometheus but for logs and\nthat seems exactly what it does for me\nit takes that same idea of streams and\nlabels and allows me to search and index\nand query the same way i would with\nprometheus and if you're familiar with\ngrafana you can actually create\ndashboards as well based on some of\nthese data just from these logs now\nmaybe i'll save that for another\ntutorial or a grafana specific one but\nit's all definitely possible and if\nyou're thinking about adding grafana or\nmaybe prometheus maybe adding loki and\nlogging will tip the scales for you so\nwhat do you think of grafana loki do you\nlike the idea of using grafana to\nactually query your logs inside of loki\ndo you like a different logging system\naltogether let me know what your\nfavorite logging system is\nin the comments section below and\nremember if you found anything in this\nvideo helpful\ndon't forget to like and subscribe\nthanks for watching and you guys are\nlightened up by my raspberry pi back\nthere i don't think it stopped i don't\nthink it stopped yet so thank you\nappreciate it everything is going to\nblow up\nno it's not going to blow up if it does\ni have automation in place to reboot it\nso\nthank you so much appreciate it",
      "content_chars": 30870,
      "published_date": null
    },
    {
      "rank": 6,
      "url": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
      "title": "How Grafana Loki retention works",
      "content": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/12) [Skip to top](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1)\n\n[Skip to main content](https://community.grafana.com/t/how-grafana-loki-retention-works/67754#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\n- [loki](https://community.grafana.com/tag/loki/14)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n\n[cancel selecting](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n\n10.9k\nviews\n2\nlinks\n7\nusers\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/d/858c86/48.png)3](https://community.grafana.com/u/dorinand \"dorinand\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/48.png)2](https://community.grafana.com/u/renaudrenaud \"renaudrenaud\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/o/cab0a1/48.png)](https://community.grafana.com/u/ottovsky \"ottovsky\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/48.png)](https://community.grafana.com/u/ericleecnl996 \"ericleecnl996\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/48.png)](https://community.grafana.com/u/bojanflander \"bojanflander\")\n\n[Jun 2022](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1 \"Jump to the first post\")\n\n1 / 11\n\n\nJun 2022\n\n\n[Apr 2024](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/12)\n\n## post by dorinand on Jun 26, 2022\n\n[![](https://avatars.discourse-cdn.com/v4/letter/d/858c86/48.png)](https://community.grafana.com/u/dorinand)\n\n[dorinand](https://community.grafana.com/u/dorinand)\n\n1\n\n[Jun 2022](https://community.grafana.com/t/how-grafana-loki-retention-works/67754 \"Post date\")\n\nI would like to set up retention for logs stored in Grafana Loki and I am not sure how the retention really works. There is more period time to configure and from documentation, it is not so clear to understand how whole process of retention works.\n\nThis is my Loki configuration:\n\n```yaml\n\ncommon:\n  instance_interface_names:\n    - \"lo\"\n  path_prefix: /loki\n  storage:\n    filesystem:\n      chunks_directory: /loki/chunks\n      rules_directory: /loki/rules\n  replication_factor: 1\n  ring:\n    instance_interface_names:\n      - \"lo\"\n    kvstore:\n      store: inmemory\n\ncompactor:\n  working_directory: /loki/compactor\n  compaction_interval: 5m\n  retention_enabled: true\n  retention_delete_delay: 5m\n  delete_request_cancel_period: 1m\n\nlimits_config:\n  retention_period: 10m\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: boltdb-shipper\n      object_store: filesystem\n      schema: v11\n      index:\n        prefix: index_\n        period: 24h\n      chunks:\n        prefix: chunk_\n        period: 168h\n```\n\nCompactor should remove old data based on this configuration. This is how I understand config file:\n\n- `compactor.compaction_interval` \\- every 5 minutes is run compactor process\n- `compactor.retention_enabled` \\- enable to apply retention policy\n- `compactor.retention_delete_delay` \\- this is the time Compactor is waiting to delete chunks after `retention_period` exceed.\n- `compactor. delete_request_cancel_period` \\- allow cancellation of delete request made by API. I think, not used in my case at all.\n- `limits_config. retention_period` \\- this is time after which data should be deleted. According to doc - `The minimum retention period is 24h.`\n\nAccording to the configuration, I would expect to have logs for last 15 minutes:\n\n- **0:00** \\- first log arrives\n- **0:05** \\- compactor is running and because of retention 10 min, no logs are meant to be deleted\n- **0:10** \\- compactor is running again and because of retention 10 min, my first log should be assign for deletion. Because of retention delay 5min, it is still not deleted at this moment.\n- **0:15** \\- compactor is running for third time. From the second run, there has been log to be deleted and retention delay 5 min has expired, that means this log can be deleted now.\n\nThis is just an example of ideal time schedule. I understand there is async processes and timing is not so precise so lets say, according to my logic, this could be done in 30-40 minutes.\n\nI am running this configuration and I can see logs for last 2,5 hours:\n\n[![image](https://us1.discourse-cdn.com/grafana/original/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b.png)\\\\\nimage1344\u00d7206 6.89 KB](https://us1.discourse-cdn.com/grafana/original/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b.png \"image\")\n\nFirst log at **20:43** and last one ad **23:00**. This is quite long according to my estimation. I do not want to use it for this short period of time but how can I estimate log retention for example for 3 days, 1 week or 2 months?\n\n**Questions:**\n\n1. How is retention calculated and processed?\n2. Do I understand Loki configuration parameters properly?\n3. How does retention differs from `chunk.period` and `index.period` under `schema_config.config`?\n\n10.9k\nviews\n2\nlinks\n7\nusers\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/d/858c86/48.png)3](https://community.grafana.com/u/dorinand \"dorinand\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/48.png)2](https://community.grafana.com/u/renaudrenaud \"renaudrenaud\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/o/cab0a1/48.png)](https://community.grafana.com/u/ottovsky \"ottovsky\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/48.png)](https://community.grafana.com/u/ericleecnl996 \"ericleecnl996\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/48.png)](https://community.grafana.com/u/bojanflander \"bojanflander\")\n\n5 months later\n\n\n## post by ottovsky on Dec 7, 2022\n\n11 days later\n\n\n## post by ericleecnl996 on Dec 19, 2022\n\n3 months later\n\n\n## post by bojanflander on Mar 30, 2023\n\n5 months later\n\n\n## post by renaudrenaud on Aug 31, 2023\n\n5 months later\n\n\n## post by arinovilyas on Jan 26, 2024\n\n## post by dorinand on Jan 27, 2024\n\n## post by dorinand on Jan 27, 2024\n\n## post by renaudrenaud on Jan 29, 2024\n\n2 months later\n\n\n## post by otakubowei on Apr 8, 2024\n\n1 year later\n\n\n## Closed on Apr 8, 2025\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-obs-stack-light-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-obs-stack-light)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1) | 4.6k | [Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/7) |\n| [Loki retention isn\u2019t working as expected\u2014logs older than 24 hours are not getting deleted](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [3](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/1) | 549 | [Feb 2025](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/4) |\n| [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14),<br>- [retention](https://community.grafana.com/tag/retention/276) | [5](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1) | 355 | [Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6) |\n| [Log retention policy](https://community.grafana.com/t/log-retention-policy/116009)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14),<br>- [retention](https://community.grafana.com/tag/retention/276) | [4](https://community.grafana.com/t/log-retention-policy/116009/1) | 5.0k | [Mar 2024](https://community.grafana.com/t/log-retention-policy/116009/5) |\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |\n\nTopic list, column headers with buttons are sortable.",
      "content_chars": 9744,
      "published_date": null
    },
    {
      "rank": 7,
      "url": "https://grafana.com/docs/loki/latest/",
      "title": "Grafana Loki documentation",
      "content": "![ObservabilityCON 2025](https://a-us.storyblok.com/f/1022730/280x40/b0872b99f9/grafana-logo-observabilitycon-2025-black.svg/m/)\n\nWatch the keynote again and signup for more on-demand sessions.\n\n\n[Watch keynote](https://grafana.com/events/observabilitycon/?plcmt=obscon2025-post-event-banner)![](https://grafana.com/media/events/grafanacon/2025/icon-close-x.svg)\n\n![ObservabilityCON 2025](https://grafana.com/media/events/obscon/2025/grafana-obscon2025-promo-logo-black.svg)\n\n\ud83d\udce2 Registration + agenda now live\nExplore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).\n\n\n[Register now](https://grafana.com/events/observabilitycon/?tech=target&plcmt=top-banner&aud=default)\n\nSearching...\n\nSite search\n\nAsk Grot AI\n\n[Try using ![Grot AI](https://grafana.com/static/img/grot-chat.svg)**Grot AI** for this query ->](https://grafana.com/grot/?chat=&from=/search)\n\nAll\n\nDocs\n\nView all results\n\nNo results.\n\nThere was an error with your request.\n\n> Documentation for automated readers\n>\n> A curated documentation index is available at: https://grafana.com/llms.txt\n>\n> A complete documentation index is available at: https://grafana.com/llms-full.txt\n>\n> These indexes can help with page discovery before fetching individual documents.\n\nThis page is also available in Markdown, which may be easier for automated readers\nand AI tools to parse than HTML. The Markdown version is available at\nhttps://grafana.com/docs/loki/latest.md, or by sending\nAccept: text/markdown to https://grafana.com/docs/loki/latest/. For broader\ndocumentation discovery, the curated index is available at https://grafana.com/llms.txt\nand the complete index is available at https://grafana.com/llms-full.txt.\n\nGrafana Loki\n\n[Documentation](https://grafana.com/docs/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)Grafana Loki\n\nOpen source\n\n![Grafana Loki](https://grafana.com/media/docs/loki/logo-grafana-loki.png)\n\n# Grafana Loki\n\nGrafana Loki is a set of open source components that can be composed into a fully featured logging stack. A small index and highly compressed chunks simplifies the operation and significantly lowers the cost of Loki.\n\n* * *\n\n## Overview\n\nUnlike other logging systems, Loki is built around the idea of only indexing metadata about your logs\u2019 labels (just like Prometheus labels).\nLog data itself is then compressed and stored in chunks in object stores such as Amazon Simple Storage Service (S3) or Google Cloud Storage (GCS), or even locally on the filesystem.\n\n## Explore\n\n[Learn about Loki\\\\\n\\\\\nLearn about the Loki architecture and components, the various deployment modes, and best practices for labels.](https://grafana.com/docs/loki/latest/get-started/) [Set up Loki\\\\\n\\\\\nView instructions for how to configure and install Loki, migrate from previous deployments, and upgrade your Loki environment.](https://grafana.com/docs/loki/latest/setup/) [Configure Loki\\\\\n\\\\\nView the Loki configuration reference and configuration examples.](https://grafana.com/docs/loki/latest/configure/) [Send logs to Loki\\\\\n\\\\\nSelect one or more clients to use to send your logs to Loki.](https://grafana.com/docs/loki/latest/send-data/) [Manage Loki\\\\\n\\\\\nLearn how to manage tenants, log ingestion, storage, queries, and more.](https://grafana.com/docs/loki/latest/operations/) [Query with LogQL\\\\\n\\\\\nInspired by PromQL, LogQL is Grafana Loki\u2019s query language. LogQL uses labels and operators for filtering.](https://grafana.com/docs/loki/latest/query/)\n\n## Grafana Loki, frequently asked questions\n\nHere are answers to some frequently asked questions about how to configure and run Loki.\n\n### Where should I start if I\u2019m new to Loki?\n\nStart with the [Loki Tutorial](https://grafana.com/docs/loki/latest/get-started/), which walks you through what Loki is, how it works, and how the components fit together.\n\n- **Try it locally.** The fastest way to experiment is to run Loki in [monolithic (single-binary) mode](https://grafana.com/docs/loki/latest/setup/install/) with a local filesystem backend and send logs to it with [Grafana Alloy](https://grafana.com/docs/alloy/latest/).\n- **Understand labels.** Loki\u2019s indexing model is label-based, which is different from most logging systems. Read [Labels](https://grafana.com/docs/loki/latest/get-started/labels/) and the [label best practices](https://grafana.com/docs/loki/latest/get-started/labels/bp-labels/) early \u2014 how you label your logs directly affects query performance and storage costs.\n- **Learn LogQL.** [LogQL](https://grafana.com/docs/loki/latest/query/) is Loki\u2019s query language. Start with simple label matchers and line filters, then explore log pipeline stages and metric queries as you need them.\n- **Explore with Grafana.** Connect Loki as a [data source in Grafana](https://grafana.com/docs/grafana/latest/datasources/loki/) and use [Explore](https://grafana.com/docs/grafana/latest/explore/) to run ad-hoc queries against your logs.\n\nThe [Grafana Labs Learning Hub](https://grafana.com/docs/learning-hub/) offers self-paced, hands-on courses relevant to Loki:\n\n- **[Send logs to Grafana Cloud using Alloy](https://grafana.com/docs/learning-hub/)** \u2014 Walk through configuring Grafana Alloy to ship logs to Loki in Grafana Cloud.\n- **[Send data from external collectors](https://grafana.com/docs/learning-hub/)** \u2014 Learn how to send logs to Loki using OpenTelemetry (OTLP) or the HTTP API, and choose the right method for your setup.\n- **[Explore your infrastructure data with Grafana Drilldown apps](https://grafana.com/docs/learning-hub/)** \u2014 Explore Loki logs visually without writing LogQL, using the Logs Drilldown app to filter by labels, detect patterns, and investigate errors.\n- **[Optimize Adaptive Logs](https://grafana.com/docs/learning-hub/)** \u2014 Reduce log volume and storage costs in Grafana Cloud by tuning which logs Loki ingests.\n\n### Should I self-host or use Grafana Cloud for logs?\n\nThe right answer depends on your team\u2019s capacity and priorities.\nChoose Grafana Cloud if you want to get up and running quickly, prefer not to manage infrastructure, or are a small team without dedicated operations resources. The free tier is generous enough for most individuals and small projects.\n\nChoose self-hosted OSS or Enterprise if you have strict data residency or compliance requirements, need to keep all data on your own infrastructure, or have an existing investment in self-managed tooling like Prometheus and want to extend it.\n\nThe feature set between Cloud and a self-managed Enterprise stack is broadly equivalent. The primary difference is operational overhead: self-hosting means you own the availability, scaling, and maintenance of every component in the stack.\n\n### What are the best practices for Loki labels vs. structured metadata?\n\nLoki\u2019s indexing model differs significantly from other observability products. Choosing the wrong fields as labels is the most common cause of poor query performance and high resource usage.\n\n**Labels** define a log stream. Every unique combination of label values creates a new stream, which is stored and indexed separately.\n\n- \u2705 Use labels for **low-cardinality** dimensions you will always filter on: `env`, `cluster`, `namespace`, `app`, `job`.\n- \u274c Do not use labels for **high-cardinality** values: pod, instance IDs, request IDs, user IDs, trace IDs, HTTP status codes, IP addresses. Each unique value creates a new stream, causing \u201ccardinality explosion\u201d that degrades ingestion and query performance.\n\n**Structured metadata** (introduced in Loki 3.0) allows attaching key-value pairs to log entries without creating new streams. Use it for values you want to filter or display but that are too high-cardinality for labels:\n\nAlloy![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```alloy\n// Example: attaching trace_id as structured metadata via Alloy\nloki.process \"default\" {\n  stage.json {\n    expressions = { \"trace_id\" = \"\" }\n  }\n\n  stage.structured_metadata {\n    values = { \"trace_id\" = \"\" }\n  }\n\n  forward_to = [loki.write.local.receiver]\n}\n\nloki.write \"local\" {\n  endpoint {\n    url = \"http://loki:3100/loki/api/v1/push\"\n  }\n}\n```\n\n**Parsed fields** (extracted at query time with `| json`, `| logfmt`, `| pattern`, `| regexp`) require no schema changes and add no indexing overhead. Prefer them for ad-hoc filtering on log content.\n\n**Rule of thumb:** If you would filter by it in _every_ query, it belongs in a label. If you only need it occasionally or it has many unique values, use structured metadata or parse it from the log line at query time.\n\n### Why does `service_name` show as `unknown_service` in Explore Logs?\n\nLoki\u2019s Explore Logs feature uses a `service_name` label to group and navigate logs. If it shows `unknown_service`, Loki could not automatically determine a service name from the incoming stream.\n\nIf a `service_name` label is already present on the stream, Loki uses it directly. Otherwise, Loki\u2019s `discover_service_name` feature looks for the first non-empty value from these label keys, in order:\n\n- service\n- app\n- application\n- app\\_name\n- name\n- app\\_kubernetes\\_io\\_name\n- container\n- container\\_name\n- k8s\\_container\\_name\n- component\n- workload\n- job\n- k8s\\_job\\_name\n\n**Common causes:**\n\n- The log shipper (Alloy, OTel Collector, kube-logging-operator) is not forwarding Kubernetes metadata as stream labels.\n- The label name uses dot notation (`service.name`). Loki normalizes label names server-side, replacing dots with underscores (for example, `service.name` becomes `service_name`).\n- `discover_service_name` is disabled in your Loki configuration.\n\n**Verify by checking your stream labels** in Explore. If none of the above keys are present as labels, configure your log shipper to include them. For Alloy, ensure `loki.source.kubernetes` or `discovery.kubernetes` is passing through pod metadata.\n\nYou can customize the list of labels Loki checks by setting `discover_service_name` in `limits_config`.\n\n### How do I fix \u201cingestion rate limit exceeded\u201d (HTTP 429) errors?\n\nA 429 error from Loki means an ingestion rate limit has been hit. Loki enforces limits both globally and per-stream.\n\n**Global ingestion limits** (applied per tenant):\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nlimits_config:\n  ingestion_rate_mb: 16        # default: 4 MB/s\n  ingestion_burst_size_mb: 32  # default: 6 MB\n```\n\n**Per-stream rate limit:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nlimits_config:\n  per_stream_rate_limit: 5MB        # default: 3MB\n  per_stream_rate_limit_burst: 15MB # default: 15MB (5x the rate limit)\n```\n\n**To identify which streams are responsible**, check the error message in your log shipper. It includes the stream labels of the offending stream. You can also query Loki\u2019s metrics endpoint for `loki_ingester_streams_created_total` broken down by tenant.\n\nIf you are self-hosting and consistently hitting limits with legitimate log volume, increase the values above in `limits_config`. If you are on Grafana Cloud, contact support to adjust your plan limits.\n\n> Note\n>\n> Increasing limits without investigating root cause can mask runaway log producers. Always check whether a specific workload or namespace is generating an unexpected spike before raising limits.\n\n### Why can\u2019t Grafana connect to Loki when both are running in Docker?\n\nWhen Grafana and Loki run as separate Docker containers, `localhost` inside the Grafana container refers to the Grafana container itself, not the host machine or the Loki container. This is the most common misconfiguration for new users.\n\n**Correct datasource URL in Docker Compose:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\n# docker-compose.yml\nservices:\n  loki:\n    image: grafana/loki:latest\n    ports:\n      - \"3100:3100\"\n\n  grafana:\n    image: grafana/grafana:latest\n    environment:\n      - GF_DATASOURCES_DEFAULT_URL=http://loki:3100\n```\n\nIn Grafana\u2019s datasource settings, use `http://loki:3100` (the Docker Compose service name) instead of `http://localhost:3100`.\n\n**For Kubernetes deployments**, use the in-cluster service DNS name:\n\n![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```none\nhttp://loki.monitoring.svc.cluster.local:3100\n```\n\n**Verify connectivity** by exec-ing into the Grafana container and running:\n\nBash![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```bash\ncurl http://loki:3100/ready\n```\n\nIf this returns `ready`, the networking is correct and the issue lies in the Grafana datasource configuration itself.\n\n### What causes \u201cToo many outstanding requests\u201d errors on my dashboard?\n\nThis error occurs when the number of concurrent queries to Loki exceeds the configured limit for a tenant. It is most common when a dashboard has four or more panels querying over a long time range against a single-node (monolithic) deployment.\n\n**Key configuration knobs:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nquery_scheduler:\n  max_outstanding_requests_per_tenant: 32000  # default: 32000\n\nfrontend:\n  max_outstanding_per_tenant: 2048            # default: 2048\n\nlimits_config:\n  split_queries_by_interval: 24h              # default: 1h\n```\n\nSplitting queries by interval reduces the load per request by breaking large time-range queries into smaller parallel chunks. For single-node deployments under sustained dashboard load, also consider increasing chunk sizes to reduce the total number of chunk reads:\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\ningester:\n  chunk_target_size: 1572864\n  max_chunk_age: 2h\n  chunk_idle_period: 30m\n```\n\nIf the issue persists at scale, consider moving from a monolithic deployment to [microservices](https://grafana.com/docs/loki/latest/get-started/deployment-modes/) mode.\n\n### How do I make a LogQL query return zero instead of \u201cno data\u201d?\n\nBy default, LogQL metric queries return no data points for intervals where no log lines matched, rather than returning `0`. This breaks percentage calculations and alert rules that expect a numeric baseline.\n\n**Workaround using `or on() vector(0)`** (mirrors the PromQL pattern):\n\nlogql![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```logql\n(\n  sum(count_over_time({app=\"my-app\"} |= \"error\" [5m]))\n  or on() vector(0)\n)\n```\n\n**For ratio/percentage queries**, guard the denominator with `> 0` to avoid dividing by zero (which produces `NaN`), and wrap the entire expression with `or on() vector(0)` so quiet periods return `0` instead of no data:\n\nlogql![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```logql\n(\n  (\n    sum(count_over_time({app=\"my-app\"} | json | status=~\"5..\" [5m]))\n    or on() vector(0)\n  )\n  /\n  (\n    sum(count_over_time({app=\"my-app\"} [5m]))\n    > 0\n  )\n)\nor on() vector(0)\n```\n\n**For alerting**, this pattern is essential. Without it, an alert rule using `count_over_time` produces no evaluation result (not `0`) during quiet periods, which can cause alerts to flap or never resolve correctly.\n\n### Why isn\u2019t my log retention policy deleting old data?\n\nRetention in Loki is handled by the **Compactor**, not by the ingester or storage backend directly. A few common reasons why old data persists even after configuring a retention period:\n\n- `retention_enabled: true` must be set under the `compactor` block, not just in `limits_config`.\n- The Compactor must be running. In monolithic deployments it is sometimes inadvertently disabled.\n- Deletion is not immediate. The Compactor runs on a schedule and only marks chunks for deletion after a configurable grace period (`retention_delete_delay`).\n- When using filesystem storage, the chunks directory size may not visibly decrease right away. The Compactor marks files for deletion first, then removes them on subsequent runs.\n\n**Minimum required configuration:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\ncompactor:\n  working_directory: /data/loki/compactor\n  retention_enabled: true\n  delete_request_store: <your-object-store>\n\nlimits_config:\n  retention_period: 360h\n```\n\nTo verify the Compactor is running and retention is active, check the Loki logs for lines referencing `compactor` and look for the metrics `loki_boltdb_shipper_compact_tables_operation_total` (compaction runs) and `loki_compactor_apply_retention_operation_total` (retention runs).\n\n## Was this page helpful?\n\n![\ud83d\udc4d](https://grafana.com/media/images/svg/thumbs-up.svg) Yes![\ud83d\udc4e](https://grafana.com/media/images/svg/thumbs-up.svg) No\n\n[Suggest an edit in GitHub](https://github.com/grafana/loki/edit/release-3.7.x/docs/sources/_index.md) [Create a GitHub issue](https://github.com/grafana/loki/issues/new?title=Documentation%20feedback:%20/docs/sources/_index.md) [Email docs@grafana.com](mailto:docs@grafana.com) [Help and support](https://grafana.com/help/) [Community](https://grafana.com/community/)\n\n## Related resources from Grafana Labs\n\nAdditional helpful documentation, links, and articles:\n\n[![webinar icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-webinar.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Getting started with logging and Grafana Loki](https://grafana.com/static/assets/featured/getting-started-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nGetting started with logging and Grafana Loki\\\\\n\\\\\nSee a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.](https://grafana.com/go/webinar/getting-started-with-logging-and-grafana-loki/?pg=docs-loki-latest&plcmt=related) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Essential Grafana Loki configuration settings](https://grafana.com/static/assets/featured/logging-with-loki-essential-configuration-settings_featured.png?w=400)\\\\\n\\\\\nEssential Grafana Loki configuration settings\\\\\n\\\\\nThis webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.](https://grafana.com/go/webinar/logging-with-loki-essential-configuration-settings/?pg=docs-loki-latest&plcmt=related-2) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Scaling and securing your logs with Grafana Loki](https://grafana.com/static/assets/featured/scaling-and-securing-your-logs-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nScaling and securing your logs with Grafana Loki\\\\\n\\\\\nThis webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.](https://grafana.com/go/webinar/scaling-and-securing-your-logs-with-grafana-loki/?pg=docs-loki-latest&plcmt=related-3)\n\nAsk Grafana Assistant",
      "content_chars": 19295,
      "published_date": null
    },
    {
      "rank": 8,
      "url": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
      "title": "LOKI Retention Policy and Chunk Deletion Issue",
      "content": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/3) [Skip to top](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/1)\n\n[Skip to main content](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [LOKI Retention Policy and Chunk Deletion Issue](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n\n[cancel selecting](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n\n[Nov 2025](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/1 \"Jump to the first post\")\n\n1 / 3\n\n\nNov 2025\n\n\n[Nov 2025](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/3)\n\n## post by rohiniraman12 on Nov 3, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/48.png)](https://community.grafana.com/u/rohiniraman12)\n\n[rohiniraman12](https://community.grafana.com/u/rohiniraman12)\n\n[Nov 2025](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057 \"Post date\")\n\nHey everyone\n\nWe\u2019re running into an issue with our on-prem **Loki setup (not on Kubernetes)** and wanted to see if anyone else has faced something similar or has ideas on how to fix it.\n\n* * *\n\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057\\#p-291697-our-setup-1)**Our Setup**\n\n- **Cluster:** 2-node Loki setup (Ingestor / Distributor / Querier roles)\n\n- **Promtail:** Managed by our DevOps team (runs as a DaemonSet \u2014 we don\u2019t have admin access, so a bit of dependency there)\n\n- **Storage:** Everything is on local filesystem mounts:\n\n\n```bash\n\n/data/loki/wal\n/data/loki/chunks\n/data/loki/index\n```\n\n- **Retention:** Configured in `loki-config.yaml` for **5 days**\n  - We\u2019ve tuned parameters like chunk block size (2 MB) to optimize space usage\n- **Deletion API:** We\u2019ve also tried using the `curl` deletion API, but understand it only _marks_ data for deletion in the index \u2014 it doesn\u2019t immediately remove chunk files.\n\n\n* * *\n\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057\\#p-291697-what-were-observing-2)**What We\u2019re Observing**\n\n1. **Chunk file timestamps keep changing**\n\n\nEven old chunk files under `/data/loki/chunks` keep getting their \u201cmodified date\u201d updated.\n\n\nWhen we check with:\n\n\n```bash\n\nls -ltrh /data/loki/chunks\n```\n\n\nwe can see the modification dates changing regularly, even for files that should be past retention.\n\n2. **Retention logic not kicking in**\n\n\nWe wrote a small custom cleanup script to delete chunks older than 5 days, but since the modified date keeps updating, nothing ever qualifies for deletion.\n\n3. **Disk usage keeps going up**\n\n\nDespite retention being set to 5 days (and even after testing the deletion API), the `/data/loki/chunks` folder size keeps increasing.\n\n\nIt doesn\u2019t seem like the old data is actually being removed.\n\n\n* * *\n\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057\\#p-291697-questions-3)**Questions**\n\n- Why would Loki be updating chunk file modification timestamps?\n\n- How can we make sure chunks are _actually_ deleted after retention (and not just marked)?\n\n- Is there a better approach to enforce retention-based cleanup when running Loki on filesystem storage \u2014 not in Kubernetes and not using object storage?\n\n- Could something like WAL replay or a background process (e.g. compactor) be touching those files and resetting timestamps?\n\n**loki version 2.9.3**\n\n**loki yaml:**\n\n\ningester:\n\n\nlifecycler:\n\n\nring:\n\n\nkvstore:\n\n\nstore: memberlist\n\n\nreplication\\_factor: 1\n\n\nfinal\\_sleep: 0s\n\n\nchunk\\_idle\\_period: 5m\n\n\nchunk\\_retain\\_period: 30s\n\n\nmax\\_transfer\\_retries: 0\n\n\nchunk\\_block\\_size: 2097152\n\n\nchunk\\_encoding: snappy\n\n\nmax\\_chunk\\_age: 2h\n\ndistributor:\n\n\nring:\n\n\nkvstore:\n\n\nstore: memberlist\n\nquerier:\n\n\nengine:\n\n\ntimeout: 1m\n\n\nquery\\_ingesters\\_within: 2h\n\nquery\\_range:\n\n\nalign\\_queries\\_with\\_step: true\n\n\nmax\\_retries: 5\n\n\nparallelise\\_shardable\\_queries: true\n\nfrontend:\n\n\nlog\\_queries\\_longer\\_than: 5s\n\n\ncompress\\_responses: true\n\nfrontend\\_worker:\n\n\nfrontend\\_address: X.X.X.X\n\nschema\\_config:\n\n\nconfigs:\n\n\n\\- from: 2020-10-24\n\n\nstore: boltdb-shipper\n\n\nobject\\_store: filesystem\n\n\nschema: v11\n\n\nindex:\n\n\nprefix: index\\_\n\n\nperiod: 24h\n\nstorage\\_config:\n\n\nboltdb\\_shipper:\n\n\nactive\\_index\\_directory: /data/loki/index\n\n\ncache\\_location: /data/loki/index\\_cache\n\n\nshared\\_store: filesystem\n\nfilesystem:\n\n\ndirectory: /data/loki/chunks\n\ncompactor:\n\n\nworking\\_directory: /data/loki/compactor\n\n\nshared\\_store: filesystem\n\n\nretention\\_enabled: true\n\n\ndelete\\_request\\_cancel\\_period: 1m\n\n\ndeletion\\_mode: filter-and-delete\n\nlimits\\_config:\n\n\ningestion\\_burst\\_size\\_mb: 500\n\n\ningestion\\_rate\\_mb: 1024\n\n\ningestion\\_rate\\_strategy: global\n\n\nmax\\_cache\\_freshness\\_per\\_query: 10m\n\n\nmax\\_global\\_streams\\_per\\_user: 50000\n\n\nmax\\_query\\_parallelism: 128\n\n\nper\\_stream\\_rate\\_limit: 500MB\n\n\nper\\_stream\\_rate\\_limit\\_burst: 500MB\n\n\nreject\\_old\\_samples: true\n\n\nreject\\_old\\_samples\\_max\\_age: 120h\n\n\nretention\\_period: 5d\n\n\nsplit\\_queries\\_by\\_interval: 15m\n\n\nenforce\\_metric\\_name: false\n\n\nmax\\_entries\\_limit\\_per\\_query: 80000\n\n\nallow\\_deletes: true\n\nchunk\\_store\\_config:\n\n\nmax\\_look\\_back\\_period: 0s\n\ntable\\_manager:\n\n\nretention\\_deletes\\_enabled: true\n\n\nretention\\_period: 5d\n\n**curl api:**\n\n\ncurl -X DELETE \u201chttp://<loki\\_host>:3100/loki/api/v1/delete\u201d\n\n\n  -H \u201cX-Scope-OrgID: <tenant\\_id>\u201d\n\n\n\u2013data-urlencode \u2018query={job=\u201cvarlogs\u201d} \\|~ \u201csensitive\\_data\u201d\u2019\n\n\n\u2013data-urlencode \u2018start=<start\\_timestamp>\u2019\n\n\n\u2013data-urlencode \u2018end=<end\\_timestamp>\u2019\n\nIf anyone has seen this behavior or has tips on how to manage chunk cleanup and ensure retention works effectively in a non-K8s setup, please share your thoughts.\n\n\nThanks in advance!\n\n\n280\nviews\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/48.png)2](https://community.grafana.com/u/rohiniraman12 \"rohiniraman12\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n## post by tonyswumac on Nov 3, 2025\n\n## post by rohiniraman12 on Nov 5, 2025\n\n### This topic will close a year after the last reply.\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-get-started-light-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-get-started-light)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [Filesystem retention not working](https://community.grafana.com/t/filesystem-retention-not-working/58192)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) | [5](https://community.grafana.com/t/filesystem-retention-not-working/58192/1) | 3.9k | [Apr 2024](https://community.grafana.com/t/filesystem-retention-not-working/58192/6) |\n| [Loki chunks deletion](https://community.grafana.com/t/loki-chunks-deletion/21196)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [4](https://community.grafana.com/t/loki-chunks-deletion/21196/1) | 5.9k | [Dec 2024](https://community.grafana.com/t/loki-chunks-deletion/21196/5) |\n| [Loki retention: chunks kinda deleted, but the size of the folder didn\u2019t decrease](https://community.grafana.com/t/loki-retention-chunks-kinda-deleted-but-the-size-of-the-folder-didnt-decrease/159758)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [2](https://community.grafana.com/t/loki-retention-chunks-kinda-deleted-but-the-size-of-the-folder-didnt-decrease/159758/1) | 109 | [Dec 2025](https://community.grafana.com/t/loki-retention-chunks-kinda-deleted-but-the-size-of-the-folder-didnt-decrease/159758/3) |\n| [Loki disk space inflation](https://community.grafana.com/t/loki-disk-space-inflation/109287)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) | [10](https://community.grafana.com/t/loki-disk-space-inflation/109287/1) | 3.2k | [Jun 2024](https://community.grafana.com/t/loki-disk-space-inflation/109287/11) |\n| [Loki - helm simple stack : retention is not working](https://community.grafana.com/t/loki-helm-simple-stack-retention-is-not-working/122775)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) | [1](https://community.grafana.com/t/loki-helm-simple-stack-retention-is-not-working/122775/1) | 667 | [May 2024](https://community.grafana.com/t/loki-helm-simple-stack-retention-is-not-working/122775/2) |\n\nTopic list, column headers with buttons are sortable.",
      "content_chars": 9545,
      "published_date": null
    },
    {
      "rank": 9,
      "url": "https://www.reddit.com/r/grafana/comments/vf48rx/logs_being_deleted_from_loki/",
      "title": "Logs being deleted from Loki? : r/grafana - Reddit",
      "content": "So, I set the compactor.retention_enabled to false but it still deletes my data. I have an explanation here on what exactly I do to find the ...",
      "content_chars": 144,
      "published_date": null
    },
    {
      "rank": 10,
      "url": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
      "title": "How to Implement Loki Retention Strategies - OneUptime",
      "content": "[Skip to main content](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#main-content)\n\n![](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view)\n\n# How to Implement Loki Retention Strategies\n\nConfigure Grafana Loki retention policies with compactor-based deletion, per-tenant limits, and storage tiering for cost-effective log management.\n\n\n![Nawaz Dhandala](https://avatars.githubusercontent.com/nawazdhandala?s=64)\n\nBy @nawazdhandala\n\n\u2022Jan 30, 2026\u2022Reading time\n10 min read\n\n[Loki](https://oneuptime.com/blog/tag/loki) [Logging](https://oneuptime.com/blog/tag/logging) [Observability](https://oneuptime.com/blog/tag/observability) [Storage](https://oneuptime.com/blog/tag/storage)\n\n## On this page\n\n[Share on X](https://twitter.com/intent/tweet?text=%20How%20to%20Implement%20Loki%20Retention%20Strategies&url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on X\")[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on LinkedIn\")[Discuss on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview&t=%20How%20to%20Implement%20Loki%20Retention%20Strategies \"Discuss on Hacker News\")\n\n* * *\n\n## Introduction [Link to Introduction](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#introduction)\n\nManaging log retention in Grafana Loki requires understanding how Loki stores data and which components handle deletion. Unlike traditional databases where you simply set a TTL, Loki's architecture involves chunks, indexes, and a compactor service that work together to enforce retention policies.\n\nThis guide covers the practical implementation of retention strategies in Loki, from basic configuration to advanced per-tenant overrides. We will walk through working configurations, explain the trade-offs between different approaches, and help you build a retention strategy that balances cost with operational requirements.\n\n## Understanding Loki's Storage Model [Link to Understanding Loki's Storage Model](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#understanding-loki-s-storage-model)\n\nBefore diving into retention configuration, you need to understand how Loki stores logs.\n\n### Chunks and Indexes [Link to Chunks and Indexes](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#chunks-and-indexes)\n\nLoki stores log data in two types of objects:\n\n| Component | Purpose | Storage Backend |\n| --- | --- | --- |\n| Chunks | Compressed log data | Object storage (S3, GCS, filesystem) |\n| Index | Metadata for querying chunks | BoltDB, Cassandra, or object storage (TSDB) |\n\nChunks contain the actual log lines, compressed and grouped by stream. The index maps labels and time ranges to specific chunks, enabling efficient queries.\n\n### The TSDB Index (Recommended) [Link to The TSDB Index (Recommended)](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#the-tsdb-index-recommended)\n\nStarting with Loki 2.8, the TSDB index is the recommended schema. It stores indexes in object storage alongside chunks, simplifying operations and enabling better retention handling.\n\nHere is a basic schema configuration using TSDB:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\n\nschema_config:\n  configs:\n    - from: 2024-01-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n```\n\nThe `period: 24h` setting creates daily index tables. This matters for retention because deletion happens at the table level for older index types.\n\n## Compactor-Based Retention [Link to Compactor-Based Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#compactor-based-retention)\n\nThe compactor is Loki's primary mechanism for enforcing retention. It runs as a separate target (or within the single binary) and handles chunk deletion based on configured policies.\n\n### Enabling the Compactor [Link to Enabling the Compactor](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#enabling-the-compactor)\n\nFirst, enable the compactor and configure retention:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\ncompactor:\n  # Working directory for compaction\n  working_directory: /loki/compactor\n\n  # How often the compactor runs\n  compaction_interval: 10m\n\n  # Enable retention enforcement\n  retention_enabled: true\n\n  # Store used for delete requests\n  delete_request_store: s3\n\n  # How often to check for chunks to delete\n  retention_delete_delay: 2h\n\n  # Number of workers for deletion\n  retention_delete_worker_count: 150\n\n  # Delete request cancel period\n  delete_request_cancel_period: 24h\n```\n\nThe `retention_delete_delay` parameter adds a safety buffer. Chunks marked for deletion wait this duration before actual removal. This gives you time to cancel accidental deletions.\n\n### Global Retention Period [Link to Global Retention Period](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#global-retention-period)\n\nSet a default retention period that applies to all tenants:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\nlimits_config:\n  # Global retention period - logs older than this are deleted\n  retention_period: 744h  # 31 days\n```\n\nThe `retention_period` value uses Go duration format. Common values:\n\n| Duration | Days | Use Case |\n| --- | --- | --- |\n| 168h | 7 | Development environments |\n| 720h | 30 | Standard production |\n| 2160h | 90 | Compliance requirements |\n| 8760h | 365 | Long-term audit logs |\n\n### Complete Basic Configuration [Link to Complete Basic Configuration](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#complete-basic-configuration)\n\nHere is a complete configuration enabling compactor retention with S3 storage:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\nauth_enabled: false\n\nserver:\n  http_listen_port: 3100\n  grpc_listen_port: 9096\n\ncommon:\n  path_prefix: /loki\n  storage:\n    s3:\n      endpoint: s3.us-east-1.amazonaws.com\n      bucketnames: loki-chunks\n      region: us-east-1\n      access_key_id: ${AWS_ACCESS_KEY_ID}\n      secret_access_key: ${AWS_SECRET_ACCESS_KEY}\n      s3forcepathstyle: false\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nschema_config:\n  configs:\n    - from: 2024-01-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /loki/tsdb-index\n    cache_location: /loki/tsdb-cache\n    cache_ttl: 24h\n\ncompactor:\n  working_directory: /loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  delete_request_store: s3\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n\nlimits_config:\n  retention_period: 720h  # 30 days\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  max_streams_per_user: 10000\n  max_entries_limit_per_query: 5000\n```\n\n## Per-Tenant Retention Overrides [Link to Per-Tenant Retention Overrides](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#per-tenant-retention-overrides)\n\nIn multi-tenant deployments, different teams often have different retention requirements. Loki supports per-tenant overrides through a runtime configuration file.\n\n### Configuring Runtime Overrides [Link to Configuring Runtime Overrides](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#configuring-runtime-overrides)\n\nFirst, tell Loki where to find the overrides file:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\nruntime_config:\n  file: /loki/runtime-config.yaml\n  period: 10s  # How often to reload\n```\n\nThen create the overrides file:\n\n```yaml\nYAMLCopy\n# runtime-config.yaml\noverrides:\n  # Team with short retention needs\n  team-development:\n    retention_period: 168h  # 7 days\n    ingestion_rate_mb: 5\n    max_streams_per_user: 5000\n\n  # Team requiring longer retention for compliance\n  team-security:\n    retention_period: 8760h  # 365 days\n    ingestion_rate_mb: 20\n    max_streams_per_user: 50000\n\n  # Default tenant with standard settings\n  team-platform:\n    retention_period: 720h  # 30 days\n```\n\n### Stream-Based Retention [Link to Stream-Based Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#stream-based-retention)\n\nYou can apply different retention periods based on log stream selectors. This enables fine-grained control within a single tenant.\n\n```yaml\nYAMLCopy\n# runtime-config.yaml\noverrides:\n  production:\n    retention_period: 720h  # Default: 30 days\n    retention_stream:\n      # Keep error logs longer\n      - selector: '{level=\"error\"}'\n        priority: 1\n        period: 2160h  # 90 days\n\n      # Keep audit logs for compliance\n      - selector: '{log_type=\"audit\"}'\n        priority: 2\n        period: 8760h  # 365 days\n\n      # Delete debug logs quickly\n      - selector: '{level=\"debug\"}'\n        priority: 3\n        period: 72h  # 3 days\n\n      # Short retention for high-volume health checks\n      - selector: '{endpoint=\"/health\"}'\n        priority: 4\n        period: 24h  # 1 day\n```\n\nThe `priority` field determines which rule wins when multiple selectors match. Higher priority values take precedence.\n\n### Dynamic Override Reloading [Link to Dynamic Override Reloading](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#dynamic-override-reloading)\n\nThe compactor automatically reloads runtime configuration at the interval specified by `period`. To verify overrides are applied, check the compactor logs:\n\n```bash\nBashCopy\n# View compactor logs for retention activity\nkubectl logs -l app=loki-compactor | grep -i retention\n```\n\nYou should see entries like:\n\n```plaintext\nTextCopy\nlevel=info ts=2026-01-30T10:00:00.000Z caller=compactor.go:450 msg=\"applying retention\" tenant=team-security retention=8760h0m0s\n```\n\n## Table Manager vs Compactor Retention [Link to Table Manager vs Compactor Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#table-manager-vs-compactor-retention)\n\nLoki historically used the Table Manager for retention with BoltDB indexes. Understanding the differences helps when migrating or maintaining older deployments.\n\n### Comparison [Link to Comparison](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#comparison)\n\n| Feature | Table Manager | Compactor |\n| --- | --- | --- |\n| Index Support | Legacy chunk/index stores and BoltDB-shipper | TSDB and BoltDB-shipper |\n| Deletion Granularity | Table-level | Chunk-level |\n| Per-Tenant Overrides | Limited | Full support |\n| Stream Selectors | No | Yes |\n| Status | Deprecated | Recommended |\n\n### Table Manager Configuration (Legacy) [Link to Table Manager Configuration (Legacy)](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#table-manager-configuration-legacy)\n\nIf you are still running BoltDB indexes, here is how Table Manager retention works:\n\n```yaml\nYAMLCopy\n# loki-config.yaml (legacy configuration)\ntable_manager:\n  retention_deletes_enabled: true\n  retention_period: 720h  # 30 days\n\n  # Table creation settings\n  index_tables_provisioning:\n    inactive_read_throughput: 1\n    inactive_write_throughput: 1\n    provisioned_read_throughput: 100\n    provisioned_write_throughput: 100\n\n  chunk_tables_provisioning:\n    inactive_read_throughput: 1\n    inactive_write_throughput: 1\n    provisioned_read_throughput: 100\n    provisioned_write_throughput: 100\n```\n\n### Migration Path [Link to Migration Path](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#migration-path)\n\nTo migrate from Table Manager to Compactor retention:\n\n1. Deploy the new schema alongside the old one\n2. Enable compactor retention for new data\n3. Let Table Manager handle old data until it ages out\n4. Remove Table Manager configuration after full migration\n\n```yaml\nYAMLCopy\n# Schema configuration for migration\nschema_config:\n  configs:\n    # Old schema - Table Manager handles retention\n    - from: 2023-01-01\n      store: boltdb-shipper\n      object_store: s3\n      schema: v12\n      index:\n        prefix: loki_index_\n        period: 24h\n\n    # New schema - Compactor handles retention\n    - from: 2024-06-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_tsdb_\n        period: 24h\n```\n\n## Deletion Markers and the Deletion API [Link to Deletion Markers and the Deletion API](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#deletion-markers-and-the-deletion-api)\n\nBeyond automatic retention, Loki supports manual deletion through its API. This is useful for removing sensitive data or clearing specific log streams.\n\n### Enabling the Deletion API [Link to Enabling the Deletion API](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#enabling-the-deletion-api)\n\n```yaml\nYAMLCopy\n# loki-config.yaml\ncompactor:\n  retention_enabled: true\n  delete_request_cancel_period: 24h\n  delete_request_store: s3\n\n# runtime-config.yaml\noverrides:\n  tenant-a:\n    deletion_mode: filter-and-delete\n```\n\n### Creating Delete Requests [Link to Creating Delete Requests](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#creating-delete-requests)\n\nUse the deletion API to mark logs for removal:\n\n```bash\nBashCopy\n# Delete all logs matching a selector within a time range\ncurl -X POST \\\n  \"http://loki:3100/loki/api/v1/delete\" \\\n  -H \"Content-Type: application/x-www-form-urlencoded\" \\\n  -d \"query={app=\\\"legacy-service\\\"}\" \\\n  -d \"start=1704067200\" \\\n  -d \"end=1706745600\"\n```\n\nThe timestamps are Unix timestamps in seconds or RFC3339 timestamps. Convert from dates:\n\n```bash\nBashCopy\n# Convert dates to Unix timestamps in seconds\nSTART=$(date -d \"2024-01-01\" +%s)\nEND=$(date -d \"2024-02-01\" +%s)\n\ncurl -X POST \\\n  \"http://loki:3100/loki/api/v1/delete\" \\\n  -d \"query={app=\\\"legacy-service\\\"}\" \\\n  -d \"start=${START}\" \\\n  -d \"end=${END}\"\n```\n\n### Listing and Canceling Delete Requests [Link to Listing and Canceling Delete Requests](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#listing-and-canceling-delete-requests)\n\nView pending deletions:\n\n```bash\nBashCopy\n# List all delete requests\ncurl \"http://loki:3100/loki/api/v1/delete\"\n```\n\nResponse:\n\n```json\nJSONCopy\n[\\\n  {\\\n    \"request_id\": \"abc123\",\\\n    \"start_time\": 1704067200,\\\n    \"end_time\": 1706745600,\\\n    \"query\": \"{app=\\\"legacy-service\\\"}\",\\\n    \"status\": \"received\",\\\n    \"created_at\": 1706800000\\\n  }\\\n]\n```\n\nCancel a pending deletion (within the cancel period):\n\n```bash\nBashCopy\ncurl -X DELETE \\\n  \"http://loki:3100/loki/api/v1/delete?request_id=abc123\"\n```\n\n### Delete Request States [Link to Delete Request States](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#delete-request-states)\n\n| State | Description |\n| --- | --- |\n| received | Request received, waiting for cancel period |\n| building | Cancel period passed, building deletion plan |\n| deleting | Actively deleting chunks |\n| processed | Deletion complete |\n\n## Storage Considerations [Link to Storage Considerations](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#storage-considerations)\n\nRetention configuration directly impacts storage costs and performance. Here are key considerations for production deployments.\n\n### Object Storage Lifecycle Policies [Link to Object Storage Lifecycle Policies](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#object-storage-lifecycle-policies)\n\nCombine Loki retention with cloud provider lifecycle policies for defense in depth:\n\n```json\nJSONCopy\n{\n  \"Rules\": [\\\n    {\\\n      \"ID\": \"loki-chunks-cleanup\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"loki/chunks/\"\\\n      },\\\n      \"Expiration\": {\\\n        \"Days\": 45\\\n      }\\\n    },\\\n    {\\\n      \"ID\": \"loki-index-cleanup\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"loki/index/\"\\\n      },\\\n      \"Expiration\": {\\\n        \"Days\": 45\\\n      }\\\n    }\\\n  ]\n}\n```\n\nSet the lifecycle policy expiration slightly longer than your Loki retention to catch any orphaned objects.\n\n### Storage Tiering for Cost Optimization [Link to Storage Tiering for Cost Optimization](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#storage-tiering-for-cost-optimization)\n\nMove older logs to cheaper storage tiers before deletion:\n\n```json\nJSONCopy\n{\n  \"Rules\": [\\\n    {\\\n      \"ID\": \"loki-tiering\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"loki/\"\\\n      },\\\n      \"Transitions\": [\\\n        {\\\n          \"Days\": 7,\\\n          \"StorageClass\": \"STANDARD_IA\"\\\n        },\\\n        {\\\n          \"Days\": 30,\\\n          \"StorageClass\": \"GLACIER_IR\"\\\n        }\\\n      ],\\\n      \"Expiration\": {\\\n        \"Days\": 90\\\n      }\\\n    }\\\n  ]\n}\n```\n\n### Chunk Size and Compression [Link to Chunk Size and Compression](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#chunk-size-and-compression)\n\nOptimize chunk configuration to reduce storage:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\ningester:\n  chunk_encoding: snappy  # Options: gzip, lz4, snappy, zstd\n  chunk_target_size: 1572864  # 1.5MB target\n  chunk_idle_period: 30m\n  chunk_block_size: 262144  # 256KB\n\n  # Flush chunks before they get too old\n  max_chunk_age: 2h\n\n  # Number of chunks to keep in memory\n  chunk_retain_period: 30s\n```\n\nCompression comparison:\n\n| Algorithm | Compression Ratio | CPU Usage | Best For |\n| --- | --- | --- | --- |\n| snappy | Good | Low | General use |\n| lz4 | Good | Low | High throughput |\n| gzip | Better | Medium | Storage constrained |\n| zstd | Best | Medium-High | Cold storage |\n\n## Monitoring Retention [Link to Monitoring Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#monitoring-retention)\n\nTrack retention effectiveness with these metrics.\n\n### Key Compactor Metrics [Link to Key Compactor Metrics](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#key-compactor-metrics)\n\n```yaml\nYAMLCopy\n# Prometheus recording rules for retention monitoring\ngroups:\n  - name: loki-retention\n    rules:\n      # Compactor deletion rate\n      - record: loki:compactor:deleted_lines_per_hour\n        expr: |\n          sum(rate(loki_compactor_deleted_lines[1h])) * 3600\n\n      # Pending deletion requests\n      - record: loki:compactor:pending_deletions\n        expr: |\n          sum(loki_compactor_pending_delete_requests_count)\n\n      # Compaction lag\n      - record: loki:compactor:lag_seconds\n        expr: |\n          time() - max(loki_compactor_apply_retention_last_successful_run_timestamp_seconds)\n```\n\n### Alerting Rules [Link to Alerting Rules](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#alerting-rules)\n\n```yaml\nYAMLCopy\n# Prometheus alerting rules\ngroups:\n  - name: loki-retention-alerts\n    rules:\n      # Alert if compactor is not running\n      - alert: LokiCompactorNotRunning\n        expr: |\n          time() - max(loki_compactor_apply_retention_last_successful_run_timestamp_seconds) > 3600\n        for: 15m\n        labels:\n          severity: warning\n        annotations:\n          summary: \"Loki compactor has not run in over an hour\"\n          description: \"Retention policies are not being enforced\"\n\n      # Alert on high deletion backlog\n      - alert: LokiDeletionBacklog\n        expr: |\n          loki_compactor_pending_delete_requests_count > 100\n        for: 1h\n        labels:\n          severity: warning\n        annotations:\n          summary: \"High number of pending deletion requests\"\n\n      # Alert if old delete requests are not being processed\n      - alert: LokiOldestDeleteRequestStalled\n        expr: |\n          loki_compactor_oldest_pending_delete_request_age_seconds > 86400\n        for: 6h\n        labels:\n          severity: info\n        annotations:\n          summary: \"Old Loki delete requests are still pending\"\n```\n\n### Grafana Dashboard Queries [Link to Grafana Dashboard Queries](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#grafana-dashboard-queries)\n\nCreate a retention monitoring dashboard:\n\n```sql\nSQLCopy\n-- Deleted lines over time\nsum(rate(loki_compactor_deleted_lines[$__rate_interval])) by (user)\n\n-- Pending delete requests\nsum(loki_compactor_pending_delete_requests_count)\n\n-- Delete requests processed over time\nsum(rate(loki_compactor_delete_requests_processed_total[$__rate_interval])) by (user)\n\n-- Oldest pending delete request age\nmax(loki_compactor_oldest_pending_delete_request_age_seconds)\n```\n\n## Production Deployment Patterns [Link to Production Deployment Patterns](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#production-deployment-patterns)\n\n### Single Binary with Retention [Link to Single Binary with Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#single-binary-with-retention)\n\nFor smaller deployments, run everything in one process:\n\n```yaml\nYAMLCopy\n# docker-compose.yml\nservices:\n  loki:\n    image: grafana/loki:3.7.1\n    ports:\n      - \"3100:3100\"\n    volumes:\n      - ./loki-config.yaml:/etc/loki/config.yaml\n      - ./runtime-config.yaml:/loki/runtime-config.yaml\n      - loki-data:/loki\n    command: -config.file=/etc/loki/config.yaml -target=all\n\nvolumes:\n  loki-data:\n```\n\n### Dedicated Compactor in Microservices Mode [Link to Dedicated Compactor in Microservices Mode](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#dedicated-compactor-in-microservices-mode)\n\nFor larger deployments, run the compactor as a dedicated service:\n\n```yaml\nYAMLCopy\n# kubernetes/compactor-deployment.yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: loki-compactor\nspec:\n  replicas: 1  # Only one compactor instance\n  selector:\n    matchLabels:\n      app: loki-compactor\n  template:\n    metadata:\n      labels:\n        app: loki-compactor\n    spec:\n      containers:\n        - name: compactor\n          image: grafana/loki:3.7.1\n          args:\n            - -config.file=/etc/loki/config.yaml\n            - -target=compactor\n          ports:\n            - containerPort: 3100\n              name: http\n          volumeMounts:\n            - name: config\n              mountPath: /etc/loki\n            - name: data\n              mountPath: /loki\n          resources:\n            requests:\n              cpu: 500m\n              memory: 1Gi\n            limits:\n              cpu: 2000m\n              memory: 4Gi\n      volumes:\n        - name: config\n          configMap:\n            name: loki-config\n        - name: data\n          persistentVolumeClaim:\n            claimName: loki-compactor-data\n```\n\nThe compactor must run as a singleton. Running multiple instances causes data corruption.\n\n### Helm Chart Configuration [Link to Helm Chart Configuration](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#helm-chart-configuration)\n\nUsing the official Loki Helm chart:\n\n```yaml\nYAMLCopy\n# values.yaml\nloki:\n  auth_enabled: false\n\n  commonConfig:\n    replication_factor: 1\n\n  storage:\n    type: s3\n    bucketNames:\n      chunks: loki-chunks\n      ruler: loki-ruler\n      admin: loki-admin\n    s3:\n      endpoint: s3.us-east-1.amazonaws.com\n      region: us-east-1\n\n  storage_config:\n    aws:\n      region: us-east-1\n      bucketnames: loki-chunks\n      s3forcepathstyle: false\n\n  schemaConfig:\n    configs:\n      - from: 2024-01-01\n        store: tsdb\n        object_store: s3\n        schema: v13\n        index:\n          prefix: loki_index_\n          period: 24h\n\n  limits_config:\n    retention_period: 720h\n\n  compactor:\n    retention_enabled: true\n    delete_request_store: s3\n    retention_delete_delay: 2h\n    retention_delete_worker_count: 150\n\n  # Runtime configuration for per-tenant overrides\n  runtimeConfig:\n    overrides:\n      team-a:\n        retention_period: 168h\n      team-b:\n        retention_period: 2160h\n\ncompactor:\n  replicas: 1\n  persistence:\n    enabled: true\n    claims:\n      - name: data\n        size: 10Gi\n```\n\n## Troubleshooting Retention Issues [Link to Troubleshooting Retention Issues](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#troubleshooting-retention-issues)\n\n### Logs Not Being Deleted [Link to Logs Not Being Deleted](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#logs-not-being-deleted)\n\nCheck the compactor is running and retention is enabled:\n\n```bash\nBashCopy\n# Check compactor status\ncurl http://loki:3100/compactor/ring\n\n# Check if retention is enabled in config\ncurl http://loki:3100/config | grep -A 10 \"compactor\"\n```\n\nCommon causes:\n\n- `retention_enabled: false` in config\n- Compactor not reaching the chunks (network or permission issues)\n- Delete delay has not passed yet\n\n### Debugging Retention Boundaries [Link to Debugging Retention Boundaries](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#debugging-retention-boundaries)\n\nVerify what the compactor sees as retention boundaries:\n\n```bash\nBashCopy\n# Check compactor logs for retention decisions\nkubectl logs deployment/loki-compactor | grep \"retention boundary\"\n```\n\n### Storage Not Decreasing [Link to Storage Not Decreasing](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#storage-not-decreasing)\n\nIf storage does not decrease after retention runs:\n\n1. Check if lifecycle policies are conflicting\n2. Verify the compactor has write access to delete objects\n3. Look for orphaned chunks from failed compactions\n\n```bash\nBashCopy\n# List objects that should have been deleted\naws s3 ls s3://loki-chunks/chunks/ --recursive | \\\n  awk '$1 < \"2024-01-01\" {print $4}'\n```\n\n### Per-Tenant Overrides Not Applied [Link to Per-Tenant Overrides Not Applied](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#per-tenant-overrides-not-applied)\n\nVerify runtime config is loaded:\n\n```bash\nBashCopy\n# Check runtime config hash\ncurl http://loki:3100/runtime_config?mode=diff\n```\n\nEnsure the tenant ID matches exactly (case-sensitive).\n\n## Best Practices Summary [Link to Best Practices Summary](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#best-practices-summary)\n\n1. **Start with compactor retention** \\- Table Manager is deprecated and has limited functionality.\n\n2. **Set conservative defaults** \\- Start with longer retention and reduce based on observed usage patterns.\n\n3. **Use stream selectors wisely** \\- Apply longer retention only to high-value logs like errors and audit trails.\n\n4. **Monitor compaction lag** \\- A backlog indicates the compactor cannot keep up with ingestion.\n\n5. **Combine with lifecycle policies** \\- Use cloud provider policies as a safety net, not the primary mechanism.\n\n6. **Test deletion in staging** \\- Verify retention policies work correctly before applying to production.\n\n7. **Document retention policies** \\- Teams need to know how long their logs persist for debugging and compliance.\n\n8. **Plan for growth** \\- Ingestion typically grows faster than deletion, so build in headroom.\n\n\n## Conclusion [Link to Conclusion](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#conclusion)\n\nImplementing effective retention in Loki requires configuring the compactor correctly and understanding how chunks and indexes interact. Start with the compactor-based approach using TSDB indexes for new deployments. Use per-tenant overrides to give teams flexibility while maintaining cost control. Monitor retention effectiveness with dedicated dashboards and alerts to catch issues before storage costs spiral.\n\nThe configurations in this guide provide a solid foundation. Adjust retention periods based on your compliance requirements, debugging needs, and budget constraints. Remember that retention is a balance - too short and you lose valuable debugging context, too long and storage costs become unsustainable.\n\nShare this article\n\n[Share on X](https://twitter.com/intent/tweet?text=%20How%20to%20Implement%20Loki%20Retention%20Strategies&url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on X\")[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on LinkedIn\")[Discuss on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview&t=%20How%20to%20Implement%20Loki%20Retention%20Strategies \"Discuss on Hacker News\")\n\n![Nawaz Dhandala](https://avatars.githubusercontent.com/nawazdhandala)\n\n### Nawaz Dhandala\n\nAuthor\n\n@nawazdhandala \u2022 Jan 30, 2026 \u2022 10 min read\n\nNawaz is building OneUptime with a passion for engineering reliable systems and improving observability.\n\n[GitHub](https://github.com/nawazdhandala)\n\nTechnically validated\u00b7 Jun 11, 2026\nView report\n\n\n### Help improve this post\n\nEvery OneUptime blog post is open source. Found a typo, an inaccuracy, or have a clearer way to explain something? Anyone can contribute \u2014 your edits make this post better for everyone who reads it next.\n\n[Edit this post on GitHub](https://github.com/oneuptime/blog/tree/master/posts/2026-01-30-loki-retention-strategies) [Contributing guidelines](https://github.com/oneuptime/blog)\n\n[Open source](https://github.com/oneuptime/oneuptime)\n\n## OneUptime is the Open-Source   Observability Platform\n\nYour complete reliability stack unified: infrastructure monitoring, incident management, status pages, and APM. Open-source and self-hostable.\n\n\n[Get started for free](https://oneuptime.com/accounts/register) [Request a demo](https://oneuptime.com/enterprise/demo)\n\n[Status Page\\\\\n\\\\\nReal-time status updates](https://oneuptime.com/product/status-page) [Incidents\\\\\n\\\\\nDetect and resolve fast](https://oneuptime.com/product/incident-management) [Monitoring\\\\\n\\\\\nMonitor any resource](https://oneuptime.com/product/monitoring) [On-Call\\\\\n\\\\\nSmart alert routing](https://oneuptime.com/product/on-call) [Maintenance\\\\\n\\\\\nPlan & communicate downtime](https://oneuptime.com/product/scheduled-maintenance) [Logs\\\\\n\\\\\nFastest log ingest and search](https://oneuptime.com/product/logs-management) [Metrics\\\\\n\\\\\nPerformance insights](https://oneuptime.com/product/metrics) [Traces\\\\\n\\\\\nEnd-to-end distributed tracing](https://oneuptime.com/product/traces) [Exceptions\\\\\n\\\\\nCatch and fix bugs early](https://oneuptime.com/product/exceptions) [Workflows\\\\\n\\\\\nAutomate any process](https://oneuptime.com/product/workflows) [Dashboards\\\\\n\\\\\nVisualize all your data](https://oneuptime.com/product/dashboards) [Kubernetes\\\\\n\\\\\nMonitor K8s clusters](https://oneuptime.com/product/kubernetes) [Profiles\\\\\n\\\\\nCPU & memory profiling](https://oneuptime.com/product/profiles)\n\n[AI\\\\\n\\\\\nDetect, diagnose, and resolve incidents with AI-powered root cause analysis and code fixes.](https://oneuptime.com/product/ai-agent)\n\n## Validation report\n\nTechnically reviewed for accuracy \u2022Jun 11, 2026\n\nLoading validation report\u2026\n\n\nAutomated technical review\nClose",
      "content_chars": 31256,
      "published_date": null
    }
  ],
  "answer_text": null,
  "citations": [],
  "raw_response": {
    "success": true,
    "data": {
      "web": [
        {
          "url": "https://grafana.com/docs/loki/latest/operations/storage/retention/",
          "title": "Log retention | Grafana Loki documentation",
          "description": "# Log retention\n## Compactor\n### Retention Configuration\n`retention_enabled` should be set to true.\n\nThis is required when retention is enabled.\n\n## Table Manager (deprecated)\n[`period_config`](https://grafana.com/docs/loki/latest/configure/#period_config) block.\n\n## Example Configuration\n```yaml\nschema_config:\n  configs:\n    - from: 2018-04-15\n      store: tsdb\n      object_store: gcs\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /loki/index\n    cache_location: /loki/index_cache\n  gcs:\n    bucket_name: GCS_BUCKET_NAME\n\nlimits_config:\n  max_query_lookback: 672h # 28 days\n  retention_period: 672h   # 28 days\n\ncompactor:\n  working_directory: /data/retention\n  delete_request_store: gcs\n  retention_enabled: true\n```",
          "position": 1,
          "markdown": "![ObservabilityCON 2025](https://a-us.storyblok.com/f/1022730/280x40/b0872b99f9/grafana-logo-observabilitycon-2025-black.svg/m/)\n\nWatch the keynote again and signup for more on-demand sessions.\n\n\n[Watch keynote](https://grafana.com/events/observabilitycon/?plcmt=obscon2025-post-event-banner)![](https://grafana.com/media/events/grafanacon/2025/icon-close-x.svg)\n\n![ObservabilityCON 2025](https://grafana.com/media/events/obscon/2025/grafana-obscon2025-promo-logo-black.svg)\n\n\ud83d\udce2 Registration + agenda now live\nExplore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).\n\n\n[Register now](https://grafana.com/events/observabilitycon/?tech=target&plcmt=top-banner&aud=default)\n\nSearching...\n\nSite search\n\nAsk Grot AI\n\n[Try using ![Grot AI](https://grafana.com/static/img/grot-chat.svg)**Grot AI** for this query ->](https://grafana.com/grot/?chat=&from=/search)\n\nAll\n\nDocs\n\nView all results\n\nNo results.\n\nThere was an error with your request.\n\n> Documentation for automated readers\n>\n> A curated documentation index is available at: https://grafana.com/llms.txt\n>\n> A complete documentation index is available at: https://grafana.com/llms-full.txt\n>\n> These indexes can help with page discovery before fetching individual documents.\n\nThis page is also available in Markdown, which may be easier for automated readers\nand AI tools to parse than HTML. The Markdown version is available at\nhttps://grafana.com/docs/loki/latest/operations/storage/retention.md, or by sending\nAccept: text/markdown to https://grafana.com/docs/loki/latest/operations/storage/retention/. For broader\ndocumentation discovery, the curated index is available at https://grafana.com/llms.txt\nand the complete index is available at https://grafana.com/llms-full.txt.\n\nLog retention\n\n[Documentation](https://grafana.com/docs/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Grafana Loki](https://grafana.com/docs/loki/latest/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Manage](https://grafana.com/docs/loki/latest/operations/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Storage](https://grafana.com/docs/loki/latest/operations/storage/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)Log retention\n\nOpen source\n\n# Log retention\n\nRetention in Grafana Loki is achieved through the [Compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor).\nBy default the `compactor.retention-enabled` flag is not set, so the logs sent to Loki live forever.\n\n> Note\n>\n> If you have a lifecycle policy configured on the object store, please ensure that it is longer than the retention period.\n\nGranular retention policies to apply retention at per tenant or per stream level are also supported by the Compactor.\n\n> Note\n>\n> The Compactor does not support retention on\n> [legacy index types](https://grafana.com/docs/loki/latest/configure/storage/#index-storage). Please use the\n> [Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/) when using legacy index types.\n> Both the Table manager and legacy index types are deprecated and may be removed in future major versions of Loki.\n\n## Compactor\n\nThe Compactor is responsible for compaction of index files and applying log retention.\n\n> Note\n>\n> Run the Compactor as a singleton (a single instance).\n\nThe Compactor runs compaction and retention on two independent schedules:\n\n- Compaction runs every `compactor.compaction-interval`.\n- Retention runs every `compactor.apply-retention-interval`. If you leave this at its default of `0s`, Loki sets it to the same value as `compactor.compaction-interval`. Whenever the two intervals are equal, Loki extends the retention interval by the smaller of `10m` or half the interval, so that compaction and retention do not run at the same time. For example, with the default `compaction_interval` of `10m`, retention runs every `15m`.\n\nIf the Compactor falls behind on either schedule, it runs the corresponding operation as soon as possible.\nBoth compaction and retention are idempotent, which means once the action has been performed, if the action is performed multiple times, it has no further effect on logs after the first time it is performed. If the Compactor restarts, it continues from where it left off.\n\n> Note\n>\n> Changes to your retention period are not retroactive, that is, they are not applied to logs that have already been ingested.\n\nThe Compactor\u2019s algorithm to apply retention is as follows:\n\n- For each day or table (one table per day with 24h index period):\n  - Compact multiple index files in the table into per-tenant index files. Result of compaction is a single index file per tenant per day.\n  - Traverse the per-tenant index. Use the tenant configuration to identify the chunks that need to be removed.\n  - Remove the references to the matching chunks from the index and add the chunk references to a marker file on disk.\n  - Upload the new modified index files.\n\nChunks are not deleted while applying the retention algorithm on the index. They are deleted asynchronously by a sweeper process\nand this delay can be configured by setting `-compactor.retention-delete-delay`. Marker files are used to keep track of the chunks pending for deletion.\n\nChunks cannot be deleted immediately for the following reasons:\n\n- Index Gateway downloads a copy of the index files to serve queries and refreshes them at a regular interval.\nHaving a delay allows the index gateways to pull the modified index file which would not contain any reference to the chunks marked for deletion.\nWithout the delay, index files (that are stale) on the gateways could refer to already deleted chunks leading to query failures.\n\n- It provides a short window of time in which to cancel chunk deletion in the case of a configuration mistake.\n\n\nBy default, marker files are written to local disk, under `<working_directory>/retention/<object_store_type>_<period_from_date>/markers/`. Marker files should be stored on a persistent disk to ensure that the chunks pending for deletion are processed even if the Compactor process restarts.\n\n> Note\n>\n> Grafana Labs recommends running Compactor as a stateful deployment (StatefulSet when using Kubernetes) with a persistent storage for storing marker files.\n\nAlternatively, you can configure the Compactor to store marker files in object storage instead of local disk, by setting `compactor.deletion-marker-object-store-prefix` (`deletion_marker_object_store_prefix`) to a prefix that ends with `/`. When set, the Compactor writes marker files to the same per-period object store bucket used for chunks, under that prefix. On startup it also copies any existing marker files from local disk to that prefix, then removes the local copies. This lets you run the Compactor without a persistent volume for marker files. Leave this setting empty to keep using local disk.\n\n### Retention Configuration\n\nThis Compactor configuration example activates retention.\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\ncompactor:\n  working_directory: /data/retention\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: gcs\nschema_config:\n  configs:\n    - from: \"2020-07-31\"\n      index:\n        period: 24h\n        prefix: index_\n      object_store: gcs\n      schema: v13\n      store: tsdb\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /data/index\n    cache_location: /data/index_cache\n  gcs:\n    bucket_name: loki\n```\n\n> Note\n>\n> Retention is only available if the index period is 24h. Single store TSDB and single store BoltDB require 24h index period.\n\n`retention_enabled` should be set to true. Without this, the Compactor will only compact tables.\n\n`delete_request_store` should be set to configure the store for delete requests. This is required when retention is enabled.\n\n`working_directory` is the directory where marked chunks and temporary tables will be saved.\n\n`compaction_interval` dictates how often compaction is applied. If the Compactor falls behind, compaction occurs as soon as possible.\n\n`apply_retention_interval` dictates how often retention is applied, independently of `compaction_interval`. Refer to [Compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor) for how the default value is derived from `compaction_interval`.\n\n`retention_delete_delay` is the delay after which the Compactor will delete marked chunks.\n\n`retention_delete_worker_count` specifies the maximum quantity of goroutine workers instantiated to delete chunks.\n\nA few other options are also relevant when tuning retention:\n\n- `retention_table_timeout` bounds how long the Compactor spends applying retention and processing delete requests on any single table. It defaults to `0s`, meaning no timeout. If the work on a table exceeds this timeout, the Compactor logs a warning and stops early rather than failing, and the remaining work is picked up again on a later run.\n- `retention_backoff_config` controls the retry behavior (minimum and maximum backoff, and number of retries) used by the sweeper when it fails to delete a marked chunk.\n- `delete_request_store_key_prefix` sets the path prefix used to store delete requests within `delete_request_store` (default `index/`).\n- `delete_request_store_db_type` sets the type of database used to store delete requests (default `boltdb`).\n\nRefer to the\n[Configuration reference](https://grafana.com/docs/loki/latest/configure/#compactor) for the full list of `compactor` options and their defaults.\n\n#### Configuring the retention period\n\nRetention period is configured within the\n[`limits_config`](https://grafana.com/docs/loki/latest/configure/#limits_config) configuration section.\n\nThere are two ways of setting retention policies:\n\n- `retention_period` which is applied globally for all log streams.\n- `retention_stream` which is only applied to log streams matching the selector.\n\n> Note\n>\n> Each `retention_stream` rule\u2019s `period` must be at least 24h. Loki rejects configuration with a shorter value, both in the global `retention_stream` list and in any per-tenant override. This minimum does not apply to the `retention_period` setting, either globally or per tenant.\n\nThis example configures global retention that applies to all tenants (unless overridden by configuring per-tenant overrides):\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\n...\nlimits_config:\n  retention_period: 744h\n  retention_stream:\n  - selector: '{namespace=\"dev\"}'\n    priority: 1\n    period: 24h\n  per_tenant_override_config: /etc/overrides.yaml\n...\n```\n\n> Note\n>\n> You can only use label matchers in the `selector` field of a `retention_stream` definition. Arbitrary LogQL expressions are not supported.\n\nPer tenant retention can be defined by configuring\n[runtime overrides](https://grafana.com/docs/loki/latest/configure/#runtime-configuration-file). For example:\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\noverrides:\n    \"29\":\n        retention_period: 168h\n        retention_stream:\n        - selector: '{namespace=\"prod\"}'\n          priority: 2\n          period: 336h\n        - selector: '{container=\"loki\"}'\n          priority: 1\n          period: 72h\n    \"30\":\n        retention_stream:\n        - selector: '{container=\"nginx\", level=\"debug\"}'\n          priority: 1\n          period: 24h\n```\n\nRetention period for a given stream is decided based on the first match in this list:\n\n1. If multiple per-tenant `retention_stream` selectors match the stream, retention period with the highest priority is picked.\n2. If multiple global `retention_stream` selectors match the stream, retention period with the highest priority is picked. This value is not considered if per-tenant `retention_stream` is set.\n3. If a per-tenant `retention_period` is specified, it will be applied.\n4. The global `retention_period` will be applied if none of the above match.\n5. If no global `retention_period` is specified, the default value of `0s` is used, which means logs are kept indefinitely.\n\n> Note\n>\n> The larger the priority value, the higher the priority. If two matching `retention_stream` rules have the same priority, Loki applies the shorter (lowest) of the two periods.\n\nStream matching uses the same syntax as Prometheus label matching:\n\n- `=`: Select labels that are exactly equal to the provided string.\n- `!=`: Select labels that are not equal to the provided string.\n- `=~`: Select labels that regex-match the provided string.\n- `!~`: Select labels that do not regex-match the provided string.\n\nThe example configurations defined above will result in the following retention periods:\n\n- For tenant `29`:\n  - Streams that have the namespace label `prod` will have a retention period of `336h` (2 weeks), even if the container label is `loki`, since the priority of the `prod` rule is higher.\n  - Streams that have the container label `loki` but are not in the namespace `prod` will have a `72h` retention period.\n  - For the rest of the streams in this tenant, per-tenant override `retention_period` value of `168h` is applied.\n- For tenant `30`:\n  - Streams that have the label `nginx` and level `debug` will have a retention period of `24h`.\n  - For the rest of the streams in this tenant the global retention period of `744h`, since there is no override specified.\n- All tenants except `29` and `30`:\n  - Streams that have the namespace label `dev` will have a retention period of `24h` hours.\n  - Streams except those with the namespace label `dev` will have the retention period of `744h`.\n\n> Note\n>\n> If you are a Grafana Cloud customer, you can use the [config self-serve API](https://grafana.com/docs/grafana-cloud/send-data/logs/config-self-serve/#configure-retention) to configure your tenant retention.\n\n## Table Manager (deprecated)\n\nRetention through the\n[Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/) is\nachieved by relying on the object store TTL feature, and will work for both\n[boltdb-shipper](https://grafana.com/docs/loki/latest/operations/storage/boltdb-shipper/) store and chunk/index stores.\n\nIn order to enable the retention support, the Table Manager needs to be\nconfigured to enable deletions and a retention period. Please refer to the\n[`table_manager`](https://grafana.com/docs/loki/latest/configure/#table_manager)\nsection of the Loki configuration reference for all available options.\nAlternatively, the `table-manager.retention-period` and\n`table-manager.retention-deletes-enabled` command line flags can be used. The\nprovided retention period needs to be a duration represented as a string that\ncan be parsed using the Prometheus common model [ParseDuration](https://pkg.go.dev/github.com/prometheus/common/model#ParseDuration). Examples: `7d`, `1w`, `168h`.\n\n> Warning\n>\n> The retention period must be a multiple of the index and chunks table\n> `period`, configured in the\n> [`period_config`](https://grafana.com/docs/loki/latest/configure/#period_config) block.\n> See the\n> [Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/#retention) documentation for\n> more information.\n\n> Note\n>\n> To avoid querying of data beyond the retention period,`max_query_lookback` config in\n> [`limits_config`](https://grafana.com/docs/loki/latest/configure/#limits_config) must be set to a value less than or equal to what is set in `table_manager.retention_period`.\n\nWhen using S3 or GCS, the bucket storing the chunks needs to have the expiry\npolicy set correctly. For more details check\n[S3\u2019s documentation](https://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html)\nor\n[GCS\u2019s documentation](https://cloud.google.com/storage/docs/managing-lifecycles).\n\nIf you must delete ingested logs, you can delete old chunks in your object store. Note,\nhowever, that this only deletes the log content and keeps the label index\nintact; you will still be able to see related labels but will be unable to\nretrieve the deleted log content.\n\nFor further details on the Table Manager internals, refer to the\n[Table Manager](https://grafana.com/docs/loki/latest/operations/storage/table-manager/) documentation.\n\nAlternatively, if the BoltDB Shipper is configured for the index store, you can enable\n[Log entry deletion](https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/) to delete log entries from a specific stream.\n\n## Example Configuration\n\nExample configuration with GCS with a 28 day retention:\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nschema_config:\n  configs:\n    - from: 2018-04-15\n      store: tsdb\n      object_store: gcs\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /loki/index\n    cache_location: /loki/index_cache\n  gcs:\n    bucket_name: GCS_BUCKET_NAME\n\nlimits_config:\n  max_query_lookback: 672h # 28 days\n  retention_period: 672h   # 28 days\n\ncompactor:\n  working_directory: /data/retention\n  delete_request_store: gcs\n  retention_enabled: true\n```\n\n## Object store lifecycle policies\n\nLoki stores chunks and indexes as objects in the configured object store (S3, GCS, Azure Blob Storage, and so on). Chunks are deleted by the [Compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor) according to your configured retention, but the Compactor only removes chunk objects: it never deletes the objects that hold cluster state, such as the index or the cluster seed.\n\nIf you also configure an object store lifecycle policy on the bucket, scope it carefully. A blanket \u201cdelete everything older than N days\u201d rule will eventually remove objects that Loki must keep, which corrupts the store and causes query failures. The note at the top of this page applies here as well: any lifecycle expiration must be longer than your retention period.\n\n> Warning\n>\n> Never apply a lifecycle rule with an empty prefix (one that targets the whole bucket). Always scope lifecycle rules to the per-tenant chunk prefixes described below.\n\n### Bucket object layout\n\nThe following objects are written to the configured bucket. The exact prefixes depend on your `schema_config` and on whether multi-tenancy is enabled, so confirm them against your own configuration before writing a lifecycle rule.\n\nExpand table\n\n| Object or prefix | Content | Safe to expire with a lifecycle policy? |\n| --- | --- | --- |\n| `<tenant_id>/` (for example, `fake/` in single-tenant mode, or your org ID per tenant) | Chunk objects (the log data). | Yes. These are the only objects a lifecycle rule should target. |\n| Index objects (under the index path prefix, `index/` by default, set by `index.path_prefix` in `schema_config`) | TSDB or BoltDB index files, written by ingesters and rewritten by the Compactor. The `index.prefix` value (for example `index_` or `loki_index_`) is the table-name prefix used inside this path, not the path itself, so match a lifecycle rule against the path prefix. | No. Loki manages the index lifecycle internally. Deleting index objects removes references to live chunks and breaks queries. |\n| `loki_cluster_seed.json` | A small file at the bucket root holding the cluster seed used by usage reporting. It is written once and never rotated. | No. A blanket age-based rule will delete it once it ages past the time to live (TTL). |\n| Delete-request store objects (a `delete_requests/` table under `delete_request_store_key_prefix`, `index/` by default, in the bucket configured by `delete_request_store`) | The Compactor\u2019s database of delete requests submitted through the<br>[Log entry deletion](https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/) API, and their processing status. | No. Removing these makes the Compactor lose track of pending delete requests. |\n| Deletion marker objects (only present if you set `deletion_marker_object_store_prefix`; otherwise markers are kept on the Compactor\u2019s local disk and never appear in the bucket) | The Compactor\u2019s record of chunks that are marked for deletion but not yet swept. Written under the configured prefix in the same per-period bucket used for chunks. | No. Removing these makes the Compactor lose track of chunks pending deletion. |\n| Ruler store objects (if the Ruler is backed by the same bucket) | Recording and alerting rule files. | No. These are configuration, not time-series data. |\n\n### Compactor retention versus object store lifecycle policies\n\nCompactor retention and object store lifecycle policies are two independent mechanisms, and they should not be configured in ways that conflict:\n\n- The Compactor is index-aware. It only deletes a chunk after it has removed every reference to that chunk from the index, and it waits `compactor.retention-delete-delay` (default `2h`) before the sweeper deletes the marked chunk, so that index gateways pick up the rewritten index first.\n- An object store lifecycle policy is index-unaware. It deletes objects purely by age and prefix, with no knowledge of whether a chunk is still referenced by the index.\n\nFor most deployments, enabling Compactor retention is sufficient and an object store lifecycle policy is not required. If you do add a lifecycle policy as a cost safety net, set its expiration **longer** than your retention period plus `compactor.retention-delete-delay`, so the Compactor always deletes chunks first and the lifecycle rule only ever catches objects the Compactor has already orphaned.\n\n### Example: Amazon S3 lifecycle policy\n\nThis policy expires only chunk objects under a single tenant prefix. Replace `fake/` with your tenant prefix (use one rule per tenant, or your org ID prefix, when multi-tenancy is enabled). The `Days` value must be larger than your retention period plus the delete delay.\n\nJSON![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```json\n{\n  \"Rules\": [\\\n    {\\\n      \"ID\": \"loki-chunk-expiration\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"fake/\"\\\n      },\\\n      \"Expiration\": {\\\n        \"Days\": 395\\\n      }\\\n    }\\\n  ]\n}\n```\n\nApply it with the AWS CLI:\n\nBash![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```bash\naws s3api put-bucket-lifecycle-configuration \\\n  --bucket YOUR_LOKI_BUCKET \\\n  --lifecycle-configuration file://lifecycle.json\n```\n\n### Example: Google Cloud Storage lifecycle rule\n\nThe equivalent GCS rule expires objects by age and prefix. As with S3, scope `matchesPrefix` to the tenant chunk prefix and keep `age` larger than your retention period plus the delete delay.\n\nJSON![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```json\n{\n  \"rule\": [\\\n    {\\\n      \"action\": {\"type\": \"Delete\"},\\\n      \"condition\": {\\\n        \"age\": 395,\\\n        \"matchesPrefix\": [\"fake/\"]\\\n      }\\\n    }\\\n  ]\n}\n```\n\nApply it with the Google Cloud CLI:\n\nBash![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```bash\ngcloud storage buckets update gs://YOUR_LOKI_BUCKET --lifecycle-file=lifecycle.json\n```\n\nFor Azure Blob Storage, use a management policy with a `prefixMatch` set to the tenant chunk prefix and the same \u201cexpiration must exceed retention plus delete delay\u201d rule.\n\n## Was this page helpful?\n\n![\ud83d\udc4d](https://grafana.com/media/images/svg/thumbs-up.svg) Yes![\ud83d\udc4e](https://grafana.com/media/images/svg/thumbs-up.svg) No\n\n[Suggest an edit in GitHub](https://github.com/grafana/loki/edit/release-3.7.x/docs/sources/operations/storage/retention.md) [Create a GitHub issue](https://github.com/grafana/loki/issues/new?title=Documentation%20feedback:%20/docs/sources/operations/storage/retention.md) [Email docs@grafana.com](mailto:docs@grafana.com) [Help and support](https://grafana.com/help/) [Community](https://grafana.com/community/)\n\n## Related resources from Grafana Labs\n\nAdditional helpful documentation, links, and articles:\n\n[![webinar icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-webinar.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Getting started with logging and Grafana Loki](https://grafana.com/static/assets/featured/getting-started-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nGetting started with logging and Grafana Loki\\\\\n\\\\\nSee a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.](https://grafana.com/go/webinar/getting-started-with-logging-and-grafana-loki/?pg=docs-loki-latest-operations-storage-retention&plcmt=related) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Essential Grafana Loki configuration settings](https://grafana.com/static/assets/featured/logging-with-loki-essential-configuration-settings_featured.png?w=400)\\\\\n\\\\\nEssential Grafana Loki configuration settings\\\\\n\\\\\nThis webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.](https://grafana.com/go/webinar/logging-with-loki-essential-configuration-settings/?pg=docs-loki-latest-operations-storage-retention&plcmt=related-2) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Scaling and securing your logs with Grafana Loki](https://grafana.com/static/assets/featured/scaling-and-securing-your-logs-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nScaling and securing your logs with Grafana Loki\\\\\n\\\\\nThis webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.](https://grafana.com/go/webinar/scaling-and-securing-your-logs-with-grafana-loki/?pg=docs-loki-latest-operations-storage-retention&plcmt=related-3)\n\nAsk Grafana Assistant",
          "metadata": {
            "facebook-domain-verification": "0nzzvug74mf2l7egl1acd75hg8l0zq",
            "zd-site-verification": "khfhpajsuhgh7m48qdm8f9",
            "twitter:title": "\n  Log retention | Grafana Loki documentation\n\n\n",
            "ogImage": "https://grafana.com/meta-generator/Log+retention@@@loki@@@13.png",
            "twitter:description": "Describes how Loki implements storage retention and retention configuration options.",
            "og:description": "Describes how Loki implements storage retention and retention configuration options.",
            "og:image:height": "630",
            "twitter:image": "https://grafana.com/meta-generator/Log+retention@@@loki@@@13.png",
            "ogSiteName": "Grafana Labs",
            "twitter:site": "@grafana",
            "robots": "index, follow",
            "og:type": "website",
            "twitter:url": "https://twitter.com/grafana",
            "og:site_name": "Grafana Labs",
            "ogTitle": "\n  Log retention | Grafana Loki documentation\n\n\n",
            "og:image:width": "1200",
            "twitter:card": "summary_large_image",
            "title": "Log retention | Grafana Loki documentation\n",
            "og:image": "https://grafana.com/meta-generator/Log+retention@@@loki@@@13.png",
            "language": "en",
            "og:title": "\n  Log retention | Grafana Loki documentation\n\n\n",
            "description": "Describes how Loki implements storage retention and retention configuration options.",
            "viewport": "width=device-width,initial-scale=1,maximum-scale=1",
            "application-name": "Grafana Labs",
            "Copyright": "Grafana Labs",
            "favicon": "https://grafana.com/static/assets/img/fav32.png",
            "scrapeId": "01a0a962-e801-720a-82e6-534e62508659",
            "sourceURL": "https://grafana.com/docs/loki/latest/operations/storage/retention/",
            "url": "https://grafana.com/docs/loki/latest/operations/storage/retention/",
            "statusCode": 200,
            "contentType": "text/html",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "4fdedad2-0fda-4449-a0cc-0ebc19c19727",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
          "title": "Loki does not delete logs after retention delete delay",
          "description": "# [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n## post by lquerinmech on Feb 16, 2023\nretention_enabled: true\n\n```\n\n  schema_config:\n```\n\n## Closed on Feb 7, 2025\n### Related topics\n| Topic | Replies | Views | Activity |\n|-|-|-|-|\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |",
          "position": 2,
          "markdown": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/8) [Skip to top](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1)\n\n[Skip to main content](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\n- [loki](https://community.grafana.com/tag/loki/14)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n\n[cancel selecting](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)\n\n4.6k\nviews\n2\nlinks\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/b782af/48.png)3](https://community.grafana.com/u/lquerinmech \"lquerinmech\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/48.png)](https://community.grafana.com/u/etc5678 \"etc5678\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/48.png)](https://community.grafana.com/u/sabirouassim \"sabirouassim\")\n\n[Feb 2023](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1 \"Jump to the first post\")\n\n1 / 8\n\n\nFeb 2023\n\n\n[Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/8)\n\n## post by lquerinmech on Feb 16, 2023\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/b782af/48.png)](https://community.grafana.com/u/lquerinmech)\n\n[lquerinmech](https://community.grafana.com/u/lquerinmech)\n\n[Feb 2023](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898 \"Post date\")\n\nI have loki on my local windows pc i run loki fine and i can store and see logs with grafana, but i am not able to delete logs after a specific amount of time: Is this even a feature of Loki?\n\nFor reference this is my config.yaml\n\n\\`auth\\_enabled: false\n\nserver:\n\nhttp\\_listen\\_port: 3100\n\ngrpc\\_listen\\_port: 9096\n\ncommon:\n\ninstance\\_addr: 127.0.0.1\n\npath\\_prefix: /tmp/loki\n\nstorage:\n\nfilesystem:\n\nchunks\\_directory: /tmp/loki/chunks\n\nrules\\_directory: /tmp/loki/rules\n\nreplication\\_factor: 1\n\nring:\n\nkvstore:\n\nstore: inmemory\n\nquery\\_range:\n\nresults\\_cache:\n\ncache:\n\nembedded\\_cache:\n\nenabled: true\n\nmax\\_size\\_mb: 100\n\ncompactor:\n\nworking\\_directory: /tmp/loki/compactor\n\nretention\\_enabled: true\n\nretention\\_delete\\_delay: 5h\n\n```\n\n  schema_config:\n```\n\nconfigs:\n\n\\- from: 2020-10-24\n\nstore: boltdb-shipper\n\nobject\\_store: filesystem\n\nschema: v11\n\nindex:\n\nprefix: index\\_\n\nperiod: 24h\n\nruler:\n\nalertmanager\\_url: [http://localhost:9093](http://localhost:9093/)``\n\n4.6k\nviews\n2\nlinks\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/b782af/48.png)3](https://community.grafana.com/u/lquerinmech \"lquerinmech\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/3be4f8/48.png)](https://community.grafana.com/u/etc5678 \"etc5678\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/48.png)](https://community.grafana.com/u/sabirouassim \"sabirouassim\")\n\n## post by tonyswumac on Feb 16, 2023\n\n## post by lquerinmech on Feb 17, 2023\n\n## post by etc5678 on Feb 17, 2023\n\n## post by tonyswumac on Feb 17, 2023\n\n## post by lquerinmech on Feb 20, 2023\n\n12 months later\n\n\n## post by sabirouassim on Feb 8, 2024\n\n1 year later\n\n\n## Closed on Feb 7, 2025\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-get-started-dark-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-get-started-dark)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [9](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1) | 10.9k | [Apr 2024](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/11) |\n| [Loki retention isn\u2019t working as expected\u2014logs older than 24 hours are not getting deleted](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [3](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/1) | 549 | [Feb 2025](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/4) |\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |\n| [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14),<br>- [retention](https://community.grafana.com/tag/retention/276) | [5](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1) | 355 | [Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6) |\n| [Logs disappearing after 11 days in storage](https://community.grafana.com/t/logs-disappearing-after-11-days-in-storage/144618)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [14](https://community.grafana.com/t/logs-disappearing-after-11-days-in-storage/144618/1) | 318 | [Dec 2025](https://community.grafana.com/t/logs-disappearing-after-11-days-in-storage/144618/15) |\n\nTopic list, column headers with buttons are sortable.",
          "metadata": {
            "og:article:section:color": "fb9d5a",
            "article:published_time": "2023-02-16T08:31:53+00:00",
            "fragment": "!",
            "language": "en",
            "ogTitle": "Loki does not delete logs after retention delete delay - Grafana Loki - Grafana Labs Community Forums",
            "og:article:tag": "loki",
            "og:ignore_canonical": "true",
            "discourse/config/environment": "%7B%22modulePrefix%22%3A%22discourse%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22%22%2C%22locationType%22%3A%22history%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3Afalse%7D%2C%22APP%22%3A%7B%22name%22%3A%22discourse%22%2C%22version%22%3A%222026.9.0-latest%2029c35dd9ebd12187abfa6cf3ebb3c8075c9989f5%22%7D%7D",
            "og:type": "website",
            "og:description": "I have loki on my local windows pc i run loki fine and i can store and see logs with grafana, but i am not able to delete logs after a specific amount of time: Is this even a feature of Loki?  For reference this is my config.yaml  `auth_enabled: false  server:  http_listen_port: 3100  grpc_listen_port: 9096  common:  instance_addr: 127.0.0.1  path_prefix: /tmp/loki  storage:  filesystem:  chunks_directory: /tmp/loki/chunks  rules_directory: /tmp/loki/rules  replication_factor: 1  ring:  kvstore: ...",
            "generator": "Discourse 2026.9.0-latest - https://github.com/discourse/discourse version 29c35dd9ebd12187abfa6cf3ebb3c8075c9989f5",
            "twitter:url": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
            "twitter:title": "Loki does not delete logs after retention delete delay - Grafana Loki - Grafana Labs Community Forums",
            "og:title": "Loki does not delete logs after retention delete delay - Grafana Loki - Grafana Labs Community Forums",
            "og:image": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "og:site_name": "Grafana Labs Community Forums",
            "title": "Loki does not delete logs after retention delete delay - Grafana Loki - Grafana Labs Community Forums",
            "color-scheme": "light",
            "google-site-verification": [
              "8aym1sTclxM_9RDJQ51QQucjfb8HYW2zCwUw3qjNkS8",
              "tDTNfz-2SQJ40TS5vbXHSzJOIXJkqRRxllNb4273uS4"
            ],
            "twitter:image": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "ogDescription": "I have loki on my local windows pc i run loki fine and i can store and see logs with grafana, but i am not able to delete logs after a specific amount of time: Is this even a feature of Loki?  For reference this is my config.yaml  `auth_enabled: false  server:  http_listen_port: 3100  grpc_listen_port: 9096  common:  instance_addr: 127.0.0.1  path_prefix: /tmp/loki  storage:  filesystem:  chunks_directory: /tmp/loki/chunks  rules_directory: /tmp/loki/rules  replication_factor: 1  ring:  kvstore: ...",
            "og:article:section": "Grafana Loki",
            "publishedTime": "2023-02-16T08:31:53+00:00",
            "ogUrl": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
            "viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content",
            "description": "I have loki on my local windows pc i run loki fine and i can store and see logs with grafana, but i am not able to delete logs after a specific amount of time: Is this even a feature of Loki? \nFor reference this is my co\u2026",
            "discourse_theme_id": "7",
            "ogImage": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "ogSiteName": "Grafana Labs Community Forums",
            "og:url": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
            "twitter:card": "summary",
            "discourse_current_homepage": "categories",
            "discourse-track-view-session-id": "e14Zyq4OWi2ioj4KYywpiL6KBmnUj4GL",
            "theme-color": "#ffffff",
            "twitter:description": "I have loki on my local windows pc i run loki fine and i can store and see logs with grafana, but i am not able to delete logs after a specific amount of time: Is this even a feature of Loki?  For reference this is my config.yaml  `auth_enabled: false  server:  http_listen_port: 3100  grpc_listen_port: 9096  common:  instance_addr: 127.0.0.1  path_prefix: /tmp/loki  storage:  filesystem:  chunks_directory: /tmp/loki/chunks  rules_directory: /tmp/loki/rules  replication_factor: 1  ring:  kvstore: ...",
            "favicon": "https://us1.discourse-cdn.com/grafana/optimized/2X/2/27fb03d0906653283f7bc272584543da514529de_2_32x32.png",
            "scrapeId": "01a0a962-e801-720a-82e6-55651701c0c3",
            "sourceURL": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
            "url": "https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898",
            "statusCode": 200,
            "contentType": "text/html; charset=utf-8",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "fa4ea447-55cc-4bc4-9384-5501b69847c6",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/",
          "title": "Log entry deletion | Grafana Loki documentation",
          "description": "Enable log entry deletion by setting retention_enabled to true in the compactor's configuration ( -compactor.retention-enabled on the command line). The ...",
          "position": 3,
          "markdown": "![ObservabilityCON 2025](https://a-us.storyblok.com/f/1022730/280x40/b0872b99f9/grafana-logo-observabilitycon-2025-black.svg/m/)\n\nWatch the keynote again and signup for more on-demand sessions.\n\n\n[Watch keynote](https://grafana.com/events/observabilitycon/?plcmt=obscon2025-post-event-banner)![](https://grafana.com/media/events/grafanacon/2025/icon-close-x.svg)\n\n![ObservabilityCON 2025](https://grafana.com/media/events/obscon/2025/grafana-obscon2025-promo-logo-black.svg)\n\n\ud83d\udce2 Registration + agenda now live\nExplore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).\n\n\n[Register now](https://grafana.com/events/observabilitycon/?tech=target&plcmt=top-banner&aud=default)\n\nSearching...\n\nSite search\n\nAsk Grot AI\n\n[Try using ![Grot AI](https://grafana.com/static/img/grot-chat.svg)**Grot AI** for this query ->](https://grafana.com/grot/?chat=&from=/search)\n\nAll\n\nDocs\n\nView all results\n\nNo results.\n\nThere was an error with your request.\n\n> Documentation for automated readers\n>\n> A curated documentation index is available at: https://grafana.com/llms.txt\n>\n> A complete documentation index is available at: https://grafana.com/llms-full.txt\n>\n> These indexes can help with page discovery before fetching individual documents.\n\nThis page is also available in Markdown, which may be easier for automated readers\nand AI tools to parse than HTML. The Markdown version is available at\nhttps://grafana.com/docs/loki/latest/operations/storage/logs-deletion.md, or by sending\nAccept: text/markdown to https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/. For broader\ndocumentation discovery, the curated index is available at https://grafana.com/llms.txt\nand the complete index is available at https://grafana.com/llms-full.txt.\n\nLog entry deletion\n\n[Documentation](https://grafana.com/docs/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Grafana Loki](https://grafana.com/docs/loki/latest/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Manage](https://grafana.com/docs/loki/latest/operations/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)[Storage](https://grafana.com/docs/loki/latest/operations/storage/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)Log entry deletion\n\nOpen source\n\n# Log entry deletion\n\nGrafana Loki supports the deletion of log entries from a specified stream.\nLog entries that fall within a specified time window and match an optional line filter are those that will be deleted.\n\nLog entry deletion is supported when the TSDB index is configured as the index store. It is also supported on the deprecated BoltDB Shipper index, but BoltDB Shipper is being removed in Loki 4.0, so new deployments should use TSDB.\n\nThe compactor component exposes REST\n[endpoints](https://grafana.com/docs/loki/latest/reference/loki-http-api/#compactor) that process delete requests.\nHitting the endpoint specifies the streams and the time window.\nThe deletion of the log entries takes place after a configurable cancellation time period expires.\n\nLog entry deletion relies on configuration of the custom logs retention workflow as defined for the\n[compactor](https://grafana.com/docs/loki/latest/operations/storage/retention/#compactor). The compactor looks at unprocessed requests which are past their cancellation period to decide whether a chunk is to be deleted or not.\n\n## Configuration\n\nEnable log entry deletion by setting `retention_enabled` to `true` in the compactor\u2019s configuration (`-compactor.retention-enabled` on the command line). The tenant\u2019s `deletion_mode` must also be `filter-only` or `filter-and-delete`, which is the case by default.\n`delete_request_store` also needs to be configured when retention is enabled to process delete requests, this determines the storage bucket that stores the delete requests.\n\n> Warning\n>\n> Be very careful when enabling retention. It is strongly recommended that you also enable versioning on your objects in object storage to allow you to recover from accidental misconfiguration of a retention setting. If you want to enable deletion but do not want to enforce retention, configure the `retention_period` setting with a value of `0s`.\n\n`deletion_mode` is a global and per-tenant setting in\n[`limits_config`](https://grafana.com/docs/loki/latest/configure/#limits_config). Its default value is `filter-and-delete`, so log entry deletion is active for every tenant as soon as `retention_enabled` is `true` and `delete_request_store` is configured, unless you explicitly change the mode. Set `deletion_mode` in the main configuration file for a global default, or override it per tenant in the\n[runtime configuration file](https://grafana.com/docs/loki/latest/configure/#runtime-configuration-file).\n\n`deletion_mode` supports three values:\n\n- `disabled`: Deletion is not allowed. Requests to the deletion API endpoints are rejected with a `403 Forbidden` response.\n- `filter-only`: Log lines matching the query in the delete request are filtered out when querying Loki. They are not removed from storage.\n- `filter-and-delete`: Log lines matching the query in the delete request are filtered out when querying Loki, and they are also removed from storage. This is the default.\n\nA delete request may be canceled within a configurable cancellation period. Set the `delete_request_cancel_period` in the compactor\u2019s YAML configuration or on the command line when invoking Loki. Its default value is 24h. To cancel a delete request that has already started processing, pass the `force=true` query parameter to the cancellation endpoint.\n\nDelete requests that include a line filter are split into smaller requests that each cover no more than `delete_max_interval` (24h by default). You can request a smaller split for a single request with the `max_interval` query parameter, but it cannot be larger than `delete_max_interval`. Delete requests without a line filter are not split. Refer to the\n[HTTP API reference](https://grafana.com/docs/loki/latest/reference/loki-http-api/#request-log-deletion) for the full set of request parameters.\n\nDelete requests themselves are stored using the database type set by `delete_request_store_db_type`, which defaults to `boltdb`. You can instead use `sqlite`. When you migrate from one database type to another, you can set `backup_delete_request_store_db_type` to `boltdb` so that delete requests are also written to a backup database. Refer to the\n[compactor configuration reference](https://grafana.com/docs/loki/latest/configure/#compactor) for details.\n\nThe deletion API endpoints are registered only when `compactor.retention_enabled` is `true`. When retention is not enabled, the endpoints are unavailable for every tenant, whatever the `deletion_mode` value is. When retention is enabled, use the `deletion_mode` tenant override to control which tenants can use the deletion API.\n\n> Note\n>\n> Deletion of log lines with line filters is one of the compactor\u2019s most resource-intensive operations. If you delete large volumes of data with line filters, refer to\n> [Horizontal scaling of Compactor](https://grafana.com/docs/loki/latest/operations/storage/compactor-horizontal-scaling/) to distribute that work across multiple compactor instances.\n\n## Was this page helpful?\n\n![\ud83d\udc4d](https://grafana.com/media/images/svg/thumbs-up.svg) Yes![\ud83d\udc4e](https://grafana.com/media/images/svg/thumbs-up.svg) No\n\n[Suggest an edit in GitHub](https://github.com/grafana/loki/edit/release-3.7.x/docs/sources/operations/storage/logs-deletion.md) [Create a GitHub issue](https://github.com/grafana/loki/issues/new?title=Documentation%20feedback:%20/docs/sources/operations/storage/logs-deletion.md) [Email docs@grafana.com](mailto:docs@grafana.com) [Help and support](https://grafana.com/help/) [Community](https://grafana.com/community/)\n\n## Related resources from Grafana Labs\n\nAdditional helpful documentation, links, and articles:\n\n[![webinar icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-webinar.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Getting started with logging and Grafana Loki](https://grafana.com/static/assets/featured/getting-started-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nGetting started with logging and Grafana Loki\\\\\n\\\\\nSee a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.](https://grafana.com/go/webinar/getting-started-with-logging-and-grafana-loki/?pg=docs-loki-latest-operations-storage-logs-deletion&plcmt=related) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Essential Grafana Loki configuration settings](https://grafana.com/static/assets/featured/logging-with-loki-essential-configuration-settings_featured.png?w=400)\\\\\n\\\\\nEssential Grafana Loki configuration settings\\\\\n\\\\\nThis webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.](https://grafana.com/go/webinar/logging-with-loki-essential-configuration-settings/?pg=docs-loki-latest-operations-storage-logs-deletion&plcmt=related-2) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Scaling and securing your logs with Grafana Loki](https://grafana.com/static/assets/featured/scaling-and-securing-your-logs-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nScaling and securing your logs with Grafana Loki\\\\\n\\\\\nThis webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.](https://grafana.com/go/webinar/scaling-and-securing-your-logs-with-grafana-loki/?pg=docs-loki-latest-operations-storage-logs-deletion&plcmt=related-3)\n\nAsk Grafana Assistant",
          "metadata": {
            "og:title": "\n  Log entry deletion | Grafana Loki documentation\n\n\n",
            "og:site_name": "Grafana Labs",
            "twitter:title": "\n  Log entry deletion | Grafana Loki documentation\n\n\n",
            "Copyright": "Grafana Labs",
            "twitter:site": "@grafana",
            "description": "Describes how Loki implements log deletion and deletion configuration options.",
            "facebook-domain-verification": "0nzzvug74mf2l7egl1acd75hg8l0zq",
            "og:description": "Describes how Loki implements log deletion and deletion configuration options.",
            "robots": "index, follow",
            "og:image:height": "630",
            "ogImage": "https://grafana.com/meta-generator/Log+entry+deletion@@@loki@@@4.png",
            "application-name": "Grafana Labs",
            "title": "Log entry deletion | Grafana Loki documentation\n",
            "ogSiteName": "Grafana Labs",
            "og:type": "website",
            "zd-site-verification": "khfhpajsuhgh7m48qdm8f9",
            "og:image": "https://grafana.com/meta-generator/Log+entry+deletion@@@loki@@@4.png",
            "og:image:width": "1200",
            "twitter:image": "https://grafana.com/meta-generator/Log+entry+deletion@@@loki@@@4.png",
            "twitter:card": "summary_large_image",
            "language": "en",
            "twitter:description": "Describes how Loki implements log deletion and deletion configuration options.",
            "ogTitle": "\n  Log entry deletion | Grafana Loki documentation\n\n\n",
            "twitter:url": "https://twitter.com/grafana",
            "viewport": "width=device-width,initial-scale=1,maximum-scale=1",
            "favicon": "https://grafana.com/static/assets/img/fav32.png",
            "scrapeId": "01a0a962-e802-730d-becf-414009734f30",
            "sourceURL": "https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/",
            "url": "https://grafana.com/docs/loki/latest/operations/storage/logs-deletion/",
            "statusCode": 200,
            "contentType": "text/html",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "fb0b7bb6-8d98-45f2-a807-b42a41dc3975",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
          "title": "Loki log retention policy and period - Grafana community forums",
          "description": "# [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n## post by lyncops on Jun 27, 2025\n```yaml\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 720h\n\ncompactor:\n  working_directory: /tmp/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n```\n\n## post by lyncops on Jun 28, 2025\n```yaml\n\nauth_enabled: false\n\nserver:\n  http_listen_port: <port>\n  grpc_listen_port: <port>\n  log_level: info\n  grpc_server_max_concurrent_streams: 1000\n\ncommon:\n  instance_addr: <localhost>\n  path_prefix: /tmp/loki\n  storage:\n    filesystem:\n      chunks_directory: /tmp/loki/chunks\n      rules_directory: /tmp/loki/rules\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nquery_range:\n  results_cache:\n    cache:\n      embedded_cache:\n        enabled: true\n        max_size_mb: 100\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 720h\n\ncompactor:\n  working_directory: /tmp/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n\npattern_ingester:\n  enabled: true\n  metric_aggregation:\n    loki_address: localhost:<port>\n\nruler:\n  alertmanager_url: http://localhost:<port>\n\nfrontend:\n  encoding: protobuf\n\n# querier:\n#   engine:\n#     enable_multi_variant_queries: true\n\n# Optional: disable anonymous reporting\n# analytics:\n#   reporting_enabled: false\n```\n\n## post by lyncops on Jun 30, 2025\n```yaml\n\nauth_enabled: false\n\nserver:\n  http_listen_port: <port>\n  grpc_listen_port: <port>\n  log_level: info\n  grpc_server_max_concurrent_streams: 1000\n\ncommon:\n  instance_addr: <localhost>\n  path_prefix: /etc/loki\n  storage:\n    filesystem:\n      chunks_directory: /etc/loki/chunks\n      rules_directory: /etc/loki/rules\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nquery_range:\n  results_cache:\n    cache:\n      embedded_cache:\n        enabled: true\n        max_size_mb: 100\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 72h\n\ncompactor:\n  working_directory: /etc/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n\npattern_ingester:\n  enabled: true\n  metric_aggregation:\n    loki_address: localhost:<port>\n\nruler:\n  alertmanager_url: http://localhost:<port>\n\nfrontend:\n  encoding: protobuf\n\n# querier:\n#   engine:\n#     enable_multi_variant_queries: true\n\n# Optional: disable anonymous reporting\n# analytics:\n#   reporting_enabled: false\n```\n\n## post by bladeno02 on Dec 3, 2025\n### Related topics\n| Topic | Replies | Views | Activity |\n|-|-|-|-|\n| [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1) | 4.6k | [Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/7) |",
          "position": 4,
          "markdown": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6) [Skip to top](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1)\n\n[Skip to main content](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\n- [loki](https://community.grafana.com/tag/loki/14),\n- [retention](https://community.grafana.com/tag/retention/276)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n\n[cancel selecting](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)\n\n355\nviews\n1\nlink\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)3](https://community.grafana.com/u/lyncops \"lyncops\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/48.png)](https://community.grafana.com/u/bladeno02 \"bladeno02\")\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1 \"Jump to the first post\")\n\n1 / 6\n\n\nJun 2025\n\n\n[Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6)\n\n## post by lyncops on Jun 27, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)](https://community.grafana.com/u/lyncops)\n\n[lyncops](https://community.grafana.com/u/lyncops)\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531 \"Post date\")\n\nHey Folks,\n\nI have configured a log retention policy in Loki to store logs for 30days, but someway somehow my logs are being kept for only 10 days.\n\nFor instance, today\u2019s date is 2025-06-27 and based on my configured log retention policy, I should be able to query logs as far back as 2025-06-01, but I can only get logs up to 2025-06-17 which seems to me the logs in loki are only retained for 10days.\n\nWhat is the issue here and how can I fix this?\n\nReference doc: [Log retention \\| Grafana Loki documentation](https://grafana.com/docs/loki/latest/operations/storage/retention/#table-manager-deprecated)\n\nThis is my loki retention configuration:\n\n```yaml\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 720h\n\ncompactor:\n  working_directory: /tmp/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n```\n\n355\nviews\n1\nlink\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)3](https://community.grafana.com/u/lyncops \"lyncops\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)2](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/48.png)](https://community.grafana.com/u/bladeno02 \"bladeno02\")\n\n## post by tonyswumac on Jun 27, 2025\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)](https://community.grafana.com/u/tonyswumac)\n\n[tonyswumac](https://community.grafana.com/u/tonyswumac)\nGrafana Champion\n\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/2 \"Post date\")\n\n1. Can you share your entire configuration, please?\n2. Do you see logs from compactor that it\u2019s actually deleting chunk files?\n3. Since you are using filesystem, do you have any local filesystem clean up process?\n\n## post by lyncops on Jun 28, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)](https://community.grafana.com/u/lyncops)\n\n[lyncops](https://community.grafana.com/u/lyncops)\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/3 \"Post date\")\n\nThis is my entire configuration\n\n```yaml\n\nauth_enabled: false\n\nserver:\n  http_listen_port: <port>\n  grpc_listen_port: <port>\n  log_level: info\n  grpc_server_max_concurrent_streams: 1000\n\ncommon:\n  instance_addr: <localhost>\n  path_prefix: /tmp/loki\n  storage:\n    filesystem:\n      chunks_directory: /tmp/loki/chunks\n      rules_directory: /tmp/loki/rules\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nquery_range:\n  results_cache:\n    cache:\n      embedded_cache:\n        enabled: true\n        max_size_mb: 100\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 720h\n\ncompactor:\n  working_directory: /tmp/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n\npattern_ingester:\n  enabled: true\n  metric_aggregation:\n    loki_address: localhost:<port>\n\nruler:\n  alertmanager_url: http://localhost:<port>\n\nfrontend:\n  encoding: protobuf\n\n# querier:\n#   engine:\n#     enable_multi_variant_queries: true\n\n# Optional: disable anonymous reporting\n# analytics:\n#   reporting_enabled: false\n```\n\nIn my compactor, I see some delete items in the directory, the content in the \u201cdeletion\u201d file is binary so i\u2019m not sure if the deletion is actually happening\n\n```csharp\n\n[root@ip-10-0-0-41 compactor]# du -sh *\n0\tdelete_requests\n16K\tdeletion\n0\tretention\n```\n\nAnd to answer your third question, I do not have any local filesystem clean up process\n\n## post by tonyswumac on Jun 30, 2025\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)](https://community.grafana.com/u/tonyswumac)\n\n[tonyswumac](https://community.grafana.com/u/tonyswumac)\nGrafana Champion\n\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/4 \"Post date\")\n\nI would advise you first to change your chunks and rules directories to something other than `/tmp`.\n\n## post by lyncops on Jun 30, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/l/6de8d8/48.png)](https://community.grafana.com/u/lyncops)\n\n[lyncops](https://community.grafana.com/u/lyncops)\n\n[Jun 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/5 \"Post date\")\n\nI have updated the chunk and rules directory to `/etc/loki` and also changed the retention policy to 3 days so that it can be easily verified if there have been any change. I will keep this thread updated of the results after 5 days (on Friday).\n\nThis is my current configuration:\n\n```yaml\n\nauth_enabled: false\n\nserver:\n  http_listen_port: <port>\n  grpc_listen_port: <port>\n  log_level: info\n  grpc_server_max_concurrent_streams: 1000\n\ncommon:\n  instance_addr: <localhost>\n  path_prefix: /etc/loki\n  storage:\n    filesystem:\n      chunks_directory: /etc/loki/chunks\n      rules_directory: /etc/loki/rules\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nquery_range:\n  results_cache:\n    cache:\n      embedded_cache:\n        enabled: true\n        max_size_mb: 100\n\nlimits_config:\n  metric_aggregation_enabled: true\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  ingestion_rate_strategy: global\n  retention_period: 72h\n\ncompactor:\n  working_directory: /etc/loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n  delete_request_store: filesystem\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: tsdb\n      object_store: filesystem\n      schema: v13\n      index:\n        prefix: index_\n        period: 24h\n\npattern_ingester:\n  enabled: true\n  metric_aggregation:\n    loki_address: localhost:<port>\n\nruler:\n  alertmanager_url: http://localhost:<port>\n\nfrontend:\n  encoding: protobuf\n\n# querier:\n#   engine:\n#     enable_multi_variant_queries: true\n\n# Optional: disable anonymous reporting\n# analytics:\n#   reporting_enabled: false\n```\n\n5 months later\n\n\n## post by bladeno02 on Dec 3, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/57b2e6/48.png)](https://community.grafana.com/u/bladeno02)\n\n[bladeno02](https://community.grafana.com/u/bladeno02)\n\n[Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6 \"Post date\")\n\nany update here, i have similar issue ,index file have 30d retention but chunk data only 10d ??\n\ni using helm loki 6.29\n\nmc find myminio/chunks/fake --older-than=\u201c9d6h\u201d \\|wc -l\n\n137\n\nbash-5.1$ mc find myminio/chunks/fake --older-than=\u201c10d\u201d \\|wc -l\n\n0\n\nbash-5.1$ mc ilm ls myminio/chunks\n\nmc: Unable to get lifecycle. The lifecycle configuration does not exist.\n\nThank !\n\n### This topic will close a year after the last reply.\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-obs-stack-light-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-obs-stack-light)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [9](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1) | 10.9k | [Apr 2024](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/11) |\n| [Log retention in Loki is not working / Query rollback is not changeing as well](https://community.grafana.com/t/log-retention-in-loki-is-not-working-query-rollback-is-not-changeing-as-well/122207)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [3](https://community.grafana.com/t/log-retention-in-loki-is-not-working-query-rollback-is-not-changeing-as-well/122207/1) | 385 | [May 2024](https://community.grafana.com/t/log-retention-in-loki-is-not-working-query-rollback-is-not-changeing-as-well/122207/4) |\n| [Loki retention isn\u2019t working as expected\u2014logs older than 24 hours are not getting deleted](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [3](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/1) | 549 | [Feb 2025](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/4) |\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |\n| [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1) | 4.6k | [Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/7) |\n\nTopic list, column headers with buttons are sortable.",
          "metadata": {
            "og:url": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
            "discourse_theme_id": "7",
            "og:article:section": "Grafana Loki",
            "viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content",
            "discourse_current_homepage": "categories",
            "twitter:description": "Hey Folks,  I have configured a log retention policy in Loki to store logs for 30days, but someway somehow my logs are being kept for only 10 days.  For instance, today\u2019s date is 2025-06-27 and based on my configured log retention policy, I should be able to query logs as far back as 2025-06-01, but I can only get logs up to 2025-06-17 which seems to me the logs in loki are only retained for 10days.  What is the issue here and how can I fix this?  Reference doc: Log retention | Grafana Loki docu...",
            "generator": "Discourse 2026.9.0-latest - https://github.com/discourse/discourse version 29c35dd9ebd12187abfa6cf3ebb3c8075c9989f5",
            "discourse/config/environment": "%7B%22modulePrefix%22%3A%22discourse%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22%22%2C%22locationType%22%3A%22history%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3Afalse%7D%2C%22APP%22%3A%7B%22name%22%3A%22discourse%22%2C%22version%22%3A%222026.9.0-latest%2029c35dd9ebd12187abfa6cf3ebb3c8075c9989f5%22%7D%7D",
            "og:type": "website",
            "twitter:url": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
            "og:image": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "og:ignore_canonical": "true",
            "twitter:title": "Loki log retention policy and period - Grafana Loki - Grafana Labs Community Forums",
            "ogSiteName": "Grafana Labs Community Forums",
            "twitter:image": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "color-scheme": "light",
            "og:site_name": "Grafana Labs Community Forums",
            "og:article:section:color": "fb9d5a",
            "google-site-verification": [
              "8aym1sTclxM_9RDJQ51QQucjfb8HYW2zCwUw3qjNkS8",
              "tDTNfz-2SQJ40TS5vbXHSzJOIXJkqRRxllNb4273uS4"
            ],
            "og:article:tag": [
              "loki",
              "retention"
            ],
            "language": "en",
            "discourse-track-view-session-id": "YcgempJ5WRstHRog0uMRXvgqjFc8oLRq",
            "publishedTime": "2025-06-27T13:33:40+00:00",
            "description": "Hey Folks, \nI have configured a log retention policy in Loki to store logs for 30days, but someway somehow my logs are being kept for only 10 days. \nFor instance, today\u2019s date is 2025-06-27 and based on my configured log\u2026",
            "article:published_time": "2025-06-27T13:33:40+00:00",
            "ogUrl": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
            "ogTitle": "Loki log retention policy and period - Grafana Loki - Grafana Labs Community Forums",
            "theme-color": "#ffffff",
            "ogDescription": "Hey Folks,  I have configured a log retention policy in Loki to store logs for 30days, but someway somehow my logs are being kept for only 10 days.  For instance, today\u2019s date is 2025-06-27 and based on my configured log retention policy, I should be able to query logs as far back as 2025-06-01, but I can only get logs up to 2025-06-17 which seems to me the logs in loki are only retained for 10days.  What is the issue here and how can I fix this?  Reference doc: Log retention | Grafana Loki docu...",
            "title": "Loki log retention policy and period - Grafana Loki - Grafana Labs Community Forums",
            "fragment": "!",
            "ogImage": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "og:description": "Hey Folks,  I have configured a log retention policy in Loki to store logs for 30days, but someway somehow my logs are being kept for only 10 days.  For instance, today\u2019s date is 2025-06-27 and based on my configured log retention policy, I should be able to query logs as far back as 2025-06-01, but I can only get logs up to 2025-06-17 which seems to me the logs in loki are only retained for 10days.  What is the issue here and how can I fix this?  Reference doc: Log retention | Grafana Loki docu...",
            "og:title": "Loki log retention policy and period - Grafana Loki - Grafana Labs Community Forums",
            "twitter:card": "summary",
            "favicon": "https://us1.discourse-cdn.com/grafana/optimized/2X/2/27fb03d0906653283f7bc272584543da514529de_2_32x32.png",
            "scrapeId": "01a0a962-e802-730d-becf-4575bef5d87f",
            "sourceURL": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
            "url": "https://community.grafana.com/t/loki-log-retention-policy-and-period/153531",
            "statusCode": 200,
            "contentType": "text/html; charset=utf-8",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "1654f2f8-4a36-4e86-8fe7-8ae297485f27",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
          "title": "Meet Grafana LOKI, a Log Aggregation System for ... - YouTube",
          "description": "I've been on a quest to find a new logging system. I've use quite a few in the past, some open source, some proprietary, and some home grown ...",
          "position": 5,
          "markdown": "![Thumbnail (1920x1080)](https://i.ytimg.com/vi/h_GGd7HfKQ8/maxresdefault.jpg)\n# [Meet Grafana LOKI, a Log Aggregation System for EVERYTHING](https://www.youtube.com/watch?v=h_GGd7HfKQ8)\n\n**Visibility**: Public\n**Uploaded by**: [Techno Tim](https://www.youtube.com/@TechnoTim)\n**Uploaded at**: 2021-11-20\n**Published at**: \n**Length**: 28:13\n**Views**: 297254\n**Likes**: 7589\n**Category**: Science & Technology\n\n## Description\n\n```\nI've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I've decided to switch.  I've switched to Grafana Loki for all of my logs for all of my systems - this includes machines, devices, docker systems and hosts, and my all of my Kubernetes clusters.  If you're thinking of using Grafana and are also looking for a fast way to log all of your systems, join me as we discuss and configure Grafana Loki.\n\nVideo Notes: https://technotim.live/posts/grafana-loki/\n\nDon't want to host it yourself?  Check out Grafana Cloud and sign up for a free account https://l.technotim.live/grafana-labs\n\nSupport me on Patreon: https://www.patreon.com/technotim\nSponsor me on GitHub: https://github.com/sponsors/timothystewart6\nSubscribe on Twitch: https://www.twitch.tv/technotim\nBecome a YouTube member: https://www.youtube.com/channel/UCOk-gHyjcWZNj3Br4oxwh0A/join\nMerch Shop \ud83d\udecd\ufe0f: https://l.technotim.live/shop\nGear Recommendations: https://l.technotim.live/gear\nGet Help in Our Discord Community: https://l.technotim.live/discord\n2nd channel: https://www.youtube.com/@TechnoTimTalks\n\n(Affiliate links may be included in this description. I may receive a small commission at no cost to you.)\n\n00:00 - Intro\n00:59 - How does Gafana Loki work?\n01:39 - What are we going to configure today?\n02:41 - What are the requirements?\n02:58 - Docker Compose Grafana Loki config\n07:48 - Loki Config\n08:35 - Promtail Config\n10:12 - Start our Loki Stack\n10:49 - How to check if it's working\n11:29 - Logging in to Grafana\n11:55 - Add Loki data source to Grafana\n12:30 - Querying Logs with Grafana and Loki\n15:03 - Configuring Promtail for Docker container logs to Loki\n16:50 - Adding the Grafana Loki Docker driver\n17:37 - Configuring the Docker daemon.json\n19:36 - Recreating Docker containers after applying\n20:37 - Querying Grafana Loki by Docker container labels and streams\n23:07 - Setting up Grafana to be a syslog receiver / endpoint\n24:44 - Setting up a kubernetes cluster with Promtail, Grafana, and Loki\n27:13 - Grafana Loki Dashboards\n27:35 - Which logging system do you use?\n27:51 - Stream Highlight - \"You guys are going to blow up my Raspberry Pi\"\"\n#Grafana #Loki #TechnoTim\n\n\"Violet Haze\" is from Harris Heller's album Bounce.\nhttps://l.technotim.live/sb-music-license\n\nThank you for watching!\n```\n\n## Transcript\n\nover the last couple of weeks i've been\nlooking for a better logging system i've\nused many different logging systems\neither at work or at home in my home lab\nand having a mix of virtual machines\nother devices containers custom code has\nmade it a little bit challenging to find\nthe right one and while i thought my\nlast logging system was the one i was\ngoing to settle on i decided to move to\nsomething else so i've recently switched\nover to grafana loki grafana loki is a\nscalable highly available multi-tenant\nlog aggregation system like prometheus\nit's designed to be cost-effective and\nvery easy to operate so there are a lot\nof similarities between loki and\nprometheus and that's why it's been\ncoined prometheus but for logs one thing\nthey share and one thing that's really\nawesome is that they both use grafana\nnow grafana is a way to query and\nvisualize almost anything which seems\nlike a great fit for logs as well so if\nyou're already using grafana or\ninvestigating it loki will fit right in\nso how does this work well there are\nthree parts really to grifana loki first\nthere's the agent the agent's name is\nprom tail and prom tail works in a push\nconfiguration and not a pole\nconfiguration so that means the agent is\ngoing to push logs into loki rather than\nquery devices and pull it and so this\none or many agents which is pushing logs\nwill push them into loki itself and loki\nis where all of these are stored but\nonce your logs and data is inside of\nloki you can then use grafana to get it\nout to query it and to visualize it i\nknow this might sound a little\ncomplicated and hard to set up but\nactually it's surprisingly easy so\nthat's what we're going to cover today\nso first we'll configure loki and get it\nup and running so we can accept some\nlogs then we'll install our agent prom\ntail so we can push logs into loki and\nthen we'll get grafana up and running\nand we'll configure the loki plugins so\nwe can start querying logs and after we\nget all this working we'll explore a few\ndifferent ways to get logs into our\nsystem we'll talk about scraping logs\nfrom a machine and then we'll talk about\nscraping logs from a docker host which\nis really awesome because all you have\nto do is set it up once and you can\ncollect all the logs from all of the\ncontainers running on that machine and\nit only takes a small amount of config\nand then we'll touch briefly on how to\nset up a syslog endpoint so you can send\nlogs from any device that supports this\nlog and then we'll also touch on how to\nsend logs from a whole entire kubernetes\ncluster but i'll go easy on the\nkubernetes i don't want you to fall\nasleep and if any of that sounds good to\nyou don't forget to give this video a\nthumbs up and subscribe if you haven't\nalready and like all of my videos i'll\nhave a link in the description to my\ndocumentation site where you can copy\nand paste all of this config so what do\nyou need to get started really you just\nneed a machine that can run docker that\ncan be a windows pc or a mac or a server\nor even a raspberry pi any of these are\nfine to run docker to be able to spin\nthese containers up and if you need help\nsetting up docker or docker compose\nthat's also in my documentation so once\nyou have daca running you'll just want\nto make sure it's working by running\ndocker dash v\nsee that you're good next make sure\nyou're inside of a directory\ni don't know where else you would be but\njust make sure you're in the right one\nso we're going to create three\ndirectories one for each of our\ncontainers\nso first we're going to do a mkdir prom\ntail and that's our agent for our logs\nthen we'll make a directory for loki\nthen we'll make a directory for grafana\nnext we'll want to create a docker\ncompose file for all three of these\nservices so we'll do a touch\ndocker-compose.yml for yaml and then we\ncan edit this file so what goes in the\nfile inside of the file goes our loki\nstack so now when i say loki stack i'm\nreferring to prom tail loki and grafana\nand here's the configuration that we're\ngoing to use so let's talk about it real\nquick so this is a typical docker\ncompose file we're going to use docker\ncomposes api's version of three then\nwe're going to create a network called\nloki now this is important because all\nthree of these containers inside of the\nstack are going to share this network\nname so the first service is called loki\nand the image we're going to use is\ngrafana loki and then we're pinning it\nto the latest version then we're going\nto create a volume for it so this volume\ncan be anywhere on this machine that\nyou're on but i'm saying that mine is in\nhome slash server admin slash docker\nvolume slash loki and then we're mapping\nthat to the inside of that container\nthat runs\nat c loki then we're exposing some ports\n3100 on the outside 3100 on the inside\nand then we're saying restart unless\nstopped and this helps if the container\nstarts crashing next is a command when\nthis container starts up and we're\nsaying dash config.file equals etsy loki\nloki dash config.yml now this is our\nlocan config and we'll have this in a\nminute but if you notice this is going\nto map to the inside of slash loki here\nand that mounts to the host so that's\nwhy we're going to put a config file\nthere here in a little bit but i'll show\nyou that here in a second and we're\nsaying hey this container belongs to\nthis network called loki the next\nservice in our stack is promtail now\nremember this is our logging agent so\nhere we're saying use the image grafana\nprom tail and then a version and we're\npinning it to that version then we're\nmounting a few volumes here so we're\nmounting bar log from our machine to var\nlog within that container and then we're\nmounting slash home server admin\ndocker volume slash prom tail on this\nmachine to the containers at c slash\nprom tail and this is just for some\npersistence here and again we're saying\nrestart unless dot and then again we're\nusing the command of dash config file\nequals etsy prom tail prom tail dash\nconfig so same idea as griffon at loki\nup there we're going to specify a config\nfile for this to use so when it mounts\nup and runs this command it can use that\nconfig file at runtime i'll show you\nthat here in a minute next is grafana so\nthis is actually going to spin up\ngrafana this one we are pinning the\nlatest because that's what grafana says\nto do next we're setting a user of 1000.\nnow this helps with permission on the\nvolume that grafana needs to write to\nnow the way you can find this is just\nrunning id and you can see your id right\nhere the uid of a thousand again that\nmight be different from you but take\nthat volume and plug it into the config\nthen speaking of volumes and persistence\nthis is where our volume is going to be\nstored for grafana so on the outside or\nthe host it's server admin slash docker\nvolumes slash grafana and then on the\ninside it's var\nlib slash grafana so this will persist\ngrafana itself so that every time you\nreboot the container you don't lose your\nconfiguration for grafana and next is\nports of 3000 on the outside and 3000 on\nthe inside now i have a quick comment\nhere that says you might need to change\nthis and this applies to every port 3000\nis a pretty common port so is 3100 so if\nyou need to change those you would\nchange it on the outside here on the\nleft side this is the one that's exposed\non your container and 3000 is a very\ncommon port for me because i run a lot\nof node stuff and they all use 3000 so i\nhad a comment here specifically for\nmyself but this applies to every port\nyou see in the configuration here\nremember change the left side left side\nis your configuration right side is the\ncontainers configuration which you can't\nchange unless you rebuild the container\nand then we see restart unless stopped\nagain and then networks loki so this\nties them all together so they're all\nusing the loki network so they can all\ncommunicate to each other within this\nstack so let's take this configuration\nhere\nand we'll copy it and we'll go back into\nour server for this docker compose file\nand we'll paste our configuration in\nthere then we'll save it then if you do\nan ls you should see your folders there\nnow you see a couple other folders that\ni have there but you should see grafana\nloki and prom tail there and then our\ndocker compose file that we created but\nbefore we start it up we need a couple\nadditional configs remember i mentioned\nearlier we need config for prom tail and\nwe need config for loki and that's\nspecified here so let's look at a file\ncalled\nloki-config.yaml here's your\nconfiguration for loki a hundred percent\nof this is the default setting that they\nsay to use for loki it has some\nconfigurations for servers ports some\npaths within the container schema config\nand a whole bunch of other configuration\nnow you shouldn't need to change\nanything in here unless you have a\nspecialized setup or specialized needs\nfor other systems that you're running so\nlet's copy this configuration and then\ngo inside of our loki folder and create\na\nloki-config.yaml file\nonce we create it then we can edit it\nand we're going to paste that\nconfiguration into there so let's save\nthat and close and now we'll need to do\nthe same thing for prom tail\nlet's go one folder up\nthen go into prom tail\nand let's do a touch\ntom tail dash config\ndot dml\nthen we can edit it\nand here is our prom tail config and\nremember prom tail is our agent to\nscrape logs so if we look here some more\nconfiguration for the server what port\nit's listening on a positions key that\npoints to a file name that points to a\nyaml file within the container then\nwe'll have a client's url with loki at\n3100\nloki slash api slash v1 slash push so\nthis is the endpoint where it's going to\npush logs and it could refer to it by\nloki because it's within this stack and\nwe can refer to it by name and then we\nhave some configuration for how to\nscrape logs now this should be a common\nbut local machine logs we're going to\nconfigure first so we're going to scrape\nlogs from this local machine and then\npush them into loki and it's saying the\ntarget is localhost and the job is\ncalled var logs and the path to var log\nand take all logs within var log and\nthen some additional configuration\ncommented out here that we'll talk about\nhere in a little bit\nso let's copy this\npaste it into prom tail dash config\nand let's save it and if we do an ls\nwithin prom tail we should see our prom\ntail config\nand if we go up into loki do the same\nthing we should see our loki dash config\nif we go up into grafana\nand look in there we shouldn't see\nanything so let's go up one more level\nand now we should see our docker compose\nfile that we created so now let's spin\nthis whole entire stack up the way i\ntypically do it is docker dash compose\nup dash d dash dash force recreate\nthere's a million ways you can do it\nthat's the way i do it here so if we run\nthis command this will now create our\nwhole entire stack so hold down loki\npulling down prom tail\nand it's pulling down grafana\nnow it's creating those containers\ndone done done so it looks like we're\nrunning if we do a docker bs really\nquick just to make sure we should see\nall three of these running so prom tail\nstarted 10 seconds ago loki started 10\nseconds ago and grafana started 10\nseconds ago so we're looking good so how\ndo we know it's working well we go to\nthe ip address of this server and we can\ngo to port 3100\nmetrics and you can see here i have some\nmetrics already you can also go to slash\nready to see if it's ready now obviously\nit should say ready if it's ready if it\ndoesn't say ready it'll usually say it's\nwaiting 15 seconds and checking the\ningester again so just keep refreshing\nthis page so this is a good sign our\ngesture is ready and we are getting\nmetrics as shown in this endpoint so now\nwe can actually log in to grafana so how\ndo we do that well it's just port 3000\nso 3000 is where grafana lives so if you\nhaven't logged into grafana before the\nusername and password is admin\nthen you'll be prompted to create a new\npassword and then once you sign in you\nhave grafana so if you're not familiar\nwith grafana this really isn't the\ntutorial for grafana i might have one in\nthe future but you get a platform for\nvisualizing logs metrics or really any\ndata but we can also query that data and\nthat's exactly what we're going to do\nwith our loki stack so the first thing\nwe need to do is actually set up our\ndata source for loki so that we can\nquery the logs\nso let's go into settings here then\nlet's click add data source and we\nshould see\nloki down here so let's select loki and\nin here very little configuration but\nthe url of our endpoint to query now\nit's suggesting http logo host 3100 but\nif you remember in our configuration\nit's an http loki 3100 and we think\neither will work but i think they\nrecommend to use loki and once we have\nthat filled in we can actually save and\ntest so now our data source is connected\nand labels are found so that's good so\nnow let's explore this data our query\nour data in here so let's go to explore\nand you want to make sure that your data\nsource is set to loki here now\nhow do we query now\nteaching you log ql which is the log\nquery language for grafana is kind of\nout of scope for this tutorial but i\nwill give you some examples on how to\nquery data and it's really\nstraightforward at least for the simple\nqueries because they suggest labels for\nyou you get kind of intellisense so\nfirst we'll start with the curly bracket\nand right away it's saying file name or\njob so these are tags from prom tail\nthat it's sending into loki\nand now loki and grafana are recognizing\nthat so let's say job let's choose job\nwhat job did we have for our logs and\nvar logs was in our prom tail\nconfiguration\nand then if we hit enter don't just hit\nenter but hit ctrl enter\nthe enter is going to create a line\nbreak but just hit ctrl enter and right\naway we can query so these are the logs\ncoming from this machine right here var\nlogs we got logs from this machine doing\nalmost nothing at all and so you can see\nall kinds of logs in here so you can see\njuno kernels juno is the name of this\nmachine you can see there looks like\nsome info messages here some warning\nmessages here and a lot of logs that may\nor may not make sense to you depending\non the type of logging you're used to\nlooking at you can actually see one here\nthere's an error here and so we can\nsearch for strings within here too but\nyou'll always have to remember that you\nhave to select first by a tag so i think\nthe way that we search these logs for a\nloose string is the intuitive\npipe equals and then a string in quotes\nso i see down there lots of juno's but i\nsee\ndocker let's search everything within\nhere for docker\nand here we go so we just filter this\nnow to docker you can see how fast we\ncan query through these logs we can\ndrill into these logs look at additional\nmetadata we can include in our filter\nor exclude from our filter oh we just\nfiltered out this entire log that we're\nin\nso we don't want to say not job\nthere we go now if you're interested in\ndoing some more advanced querying i\nhighly recommend checking out their log\nql syntax but really it's not that\ncomplex for me most of the time i'm\nlooking for a needle in the haystack i'm\nlooking for a specific phrase or\nkeywords within my logs and then i'm\nable to narrow down and figure out maybe\nwhat the problem is so this is cool but\nthis is only for this machine's logs\nwhich may or may not be helpful if you\nremember in prom tail we had some\nadditional configuration commented out\nthat was configuration for our docker\ncontainers this is where it gets really\ncool because currently the way that you\ncheck for docker logs is you do docker\nlogs then choose your container\nwe want to say heimdall we say docker\nlogs heimdall we don't see any errors\nthere so then we see docker logs and\nlet's choose another one you can choose\npoor tanner\nsee some errors or some logs there\nand then we can do docker logs up\ntankuma check out uptime kuma and it has\nlots of errors this isn't efficient or\nfun so to make this more fun and more\nefficient we can actually configure prom\ntail to log all of the standard out all\nof these logs that we see here\nto loki and one piece of configuration\nsuper cool so let's go back into prom\ntail\nand let's edit this config now i'll\nbring this up in vs code so you can see\na little bit better but instead of\nscraping logs from the machine let's\nactually now scrape logs from docker so\nthis is saying hey the job name is\ncalled docker there's a pipeline stage\ncalled docker\nand then we're going to create a label\ncall docker and then we're going to grab\nall the logs from docker slash\ncontainers and then everything within\nhere every subfolder that has the file\nname of dash json.log so this does exist\nbut we need to make one more\nconfiguration but let's get this in\nplace first\nso let's copy this let's get rid of our\nprom tail config or we could have\nuncommented that out and let's update it\nwith our docker locks and we'll get rid\nof the host machine logs arguably you\ncan keep them there totally up to you\nbut let's save this close out of here so\nin order to log all of our containers\nlogs to loki we actually need to install\na docker driver or a plug-in for docker\nso that we can push all of those logs to\nloki and so there is a plug-in to do\nthis and it's actually really cool and\nsuper simple to spin up so to do it we\nneed to install the grafana loki docker\ndriver client and to do that it's just\nas simple as running this command right\nhere so docker plug-in install grafana\nloki docker driver latest so this is the\ncontainer alias is loki and grant all\npermissions i know that sounds scary but\nthat's how we get access to all of these\nlogs to send them into loki so let's\ngrab this go back into our machine and\nthen let's run this so this pulled down\nthe container and configured the driver\nfor us there's one more thing we'll need\nto do first just check to make sure it's\ninstalled so docker plug-ins ls and we\nshould see loki here so the loki logging\ndriver and enabled is true next if we go\nback to where we configured the driver\nit mentions in here we need to change a\ncouple of things so we're gonna have to\nconfigure the daemon config the\ndaemon.json located in etsy docker on\nthis machine so we can configure it in\ntwo ways there's a shorthand version and\nthen there's the configuration with some\nadditional options so there's the loki\nserver and then there's the loki batch\nsize so how big is the batch of logs to\npush and then for our configuration for\nour daemon.json for docker it's going to\nbe log driver is loki log options and\nthen inside of this object we have a\nproperty loki url which is the url of\nour server that we're on and here we can\nrefer to it as localhost so you should\nbe able to copy and paste this no\nproblem\nand then the batch size of 400 again\nlet's copy this and remember it said\nthat we need to update the\ndocker'sdaemon.js\nand etsy docker\nso on our server or machine we should be\nable to edit etsc docker\ndaemon.json\nnow this file may or may not exist so\nyou'll just want to edit it and if it's\nnot there it'll create it and here we're\ngoing to paste our options\nsay this then it says after changing\nthis file we'll need to restart the\ndocker daemon for the changes to take\neffect all newly created containers from\nthe host will then send logs to loki via\nthe driver so keep that in mind newly\ncreated so we have some containers\nrunning so we might have to recreate\nthem but that's super easy with a\ncommand but the most important piece\nhere is that we need to restart the\ndocker daemon so we should be able to\nrun sudo system ctl restart you should\nbe able to choose docker\nokay it looks like it restarted docker\ndocker dash v just to make sure it's\nrunning and it is okay so let's go back\nto grafana now really quick so if we go\nback to grafana refresh to make sure\nit's working and make sure you're in\nexplorer\ngo back into our queries we don't see\nadditional labels yet so we should have\none here called docker and containers\nand a whole bunch but remember i said in\nthe documentation it said only for newly\ncreated containers so let's actually\nrecreate our containers that we're\nrunning so in order to recreate these at\nleast for me i have all of my docker\ncompose files within a folder\nso if i go into heimdall i should have\nmy docker compose file and i can run\ndocker\ndash compose horse recreate\nso recreate my heindall container\nand let's do the same for my uptime kuma\nand let's do the same for file browser\nand that should be good so let's do a\ndocker ps to see what's running i have\ncontainers running i see that some are\nrecreated and restarted so now let's go\nback in grafana\nwe go back to grafana and we go into our\nquery\nwhen we do a curly bracket now we see\nsome additional labels so this is really\ncool so we can say container name equals\nand it will suggest one so container\nname equals heimdall\nand\ncontrol enter\nand we can see the logs from heindel\nright here so this just happened really\ncool really cool okay so let's go back\nand if you hit control space at any time\nyou'll get intellisense or suggestions\njust like you would in any ide or vs\ncode\nlet's choose file browser hit enter\ncontrol enter\ni am hitting ctrl enter but control is\nbroken on my keyboard i need a new\nkeyboard\nkeep telling myself that but ctrl enter\nthe other control enter and we can see\nour logs from file browser awesome i\nhave an error here but that's expected\nthat was from my demo and then if we\nlook and what was the last one uptime\nkuma let's see how he's doing control\nenter and we can see our logs here\nreally cool and you can actually combine\nthese logs too if you want to say\nuptight kuma and this doesn't make a\nwhole bunch of sense but the host is\njuno which it is you can hit enter so if\nyou were\ngathering logs from multiple docker\nhosts where they both had uptime kuma\ncontainer names this would filter on\njuno\nwhich i only have one server running but\nif i hit filter on tests this will\nprobably throw an error because i don't\nhave one called test\nbut again if i wanted to search for\nuptime kuma\nsearch and then if we wanted to do the\npipe equals the most intuitive thing\nuh let's see uh k3s\nand enter now we just filtered all of\nour logs for the container name optim\nkuma that contain k3s in there so pretty\npretty awesome pretty powerful stuff and\nso if you have 20 30 10 to however many\ncontainers running now all of those logs\nwill be\ncaptured inside of loki just by editing\nthe daemon jason and then having a\nconfig within prom tail it's a lot of\nwords i know but it'll make sense i\npromise now if you wanted to save this\nquery say in your favorites you could\nyou could bookmark this or you could\njust go into query history look at the\nlast query we just ran\nand then start and then to get back\nlet's say that was closed go into query\nhistory go into star and then you can\nrun this query and the really cool thing\nabout this is it fits within your\necosystem if you're already using\ngrafana so a couple more things i\nmentioned i'll touch on real quick\nassist logging so you can actually set\nthis up to be a syslog target for any of\nyour devices so let's say you're running\nsystems that aren't containers let's say\nyour network firewall or your virtual\nmachine or your windows machine or your\nraspberry pi and you want to pipe those\nlogs into loki as well well you would\njust set up prom tail to host a\nsyslogging endpoint and so to set it up\nas a logging endpoint or a syslog\nreceiver we would add this configuration\nright here so this configuration would\nactually go into prom tail i'll put it\nin there because it'll make a little\nmore sense but if we were to add it to\nour prom tail configuration\nwe could add it here and you could\nobviously comment this out or you can\nadd two jobs but you can have multiple\njobs i just commented these out but by\nadding this configuration we have a job\nnow called syslog it's gonna listen on\n0.0.0.0\non port 1514 and listen for syslogs to\ncome in and so if you enable this then\nyou're able to receive syslogs from any\nmachine now a word of advice should\neither format those syslogs going out or\nformat them before they come into here\nnow it's not a big deal most of the time\nthey'll look pretty good but depending\non your device and how it formats\nsyslogs you might not see them in the\nway you would expect to see them within\ngrafana and another thing before i\nforget because i just noticed this port\n1514 they'll have to open up on your\nprom tail docker convict but if you need\nhelp with configuring that leave a\ncomment below and we'll try to work\nthrough it but that should be all you\nneed to do so the last thing i mentioned\nwas kubernetes not going to spend a ton\nof time on it but you can apply the same\nidea that we applied to docker to\nkubernetes so just think about it in\nkubernetes you have many containers\nrunning many pods running and you want\nto get all of those logs inside of loki\nwell you have a couple of options one\nyou can spin up prom tail there and dump\nall of those logs into this container or\nyou could run your whole entire loki\nstack in kubernetes which is super easy\nthere's a simple helm command you can do\nto run it and i'll actually have a blog\npost article in the documentation below\nof how to do it in kubernetes and\nliterally it took me 10 minutes to get\nrunning if that a lot faster than the\ndocker version because most of it's\npre-configured with helm helm's just a\npackage manager for kubernetes but\nanyways once you get all of your\ncontainers dumping their standard out\nand standard air into loki it's really\npowerful so here's my own home\nproduction version of loki that's\nactually running in kubernetes and it's\nscraping all of the logs from my\nkubernetes containers and dumping them\ninto loki kind of inception but it works\ngreat so right away if i do curly\nbracket you can see i have lots of\nlabels so these are labels that are\nspecific to kubernetes that it already\nhas and discovered\nyou can see i can type in container name\nequals and i can see\nall of my containers that match this\nquery then i can query this container\nand look at them so not much different\nfrom the docker version or any other\nversion but i get all of these labels\nautomatically as these logs come in\nso i could say the app kubernetes io\ninstance is loki and see the logs for\nloki or i can say the chart is\nprometheus\nand look at the logs for that there's no\nlogs there it's a weird label but you\nget the idea or i can say the specific\npod name you can see my pods if i had\nmultiple pods running is\nmy technotem little link server you can\nsee them here and so you can see how\npowerful this is i can log physical\nmachines network devices docker\ncontainers kubernetes clusters really\nanything really fast and the nice part\nabout it is it fits right into the\ngrafana ecosystem it's always been\ncompared to prometheus but for logs and\nthat seems exactly what it does for me\nit takes that same idea of streams and\nlabels and allows me to search and index\nand query the same way i would with\nprometheus and if you're familiar with\ngrafana you can actually create\ndashboards as well based on some of\nthese data just from these logs now\nmaybe i'll save that for another\ntutorial or a grafana specific one but\nit's all definitely possible and if\nyou're thinking about adding grafana or\nmaybe prometheus maybe adding loki and\nlogging will tip the scales for you so\nwhat do you think of grafana loki do you\nlike the idea of using grafana to\nactually query your logs inside of loki\ndo you like a different logging system\naltogether let me know what your\nfavorite logging system is\nin the comments section below and\nremember if you found anything in this\nvideo helpful\ndon't forget to like and subscribe\nthanks for watching and you guys are\nlightened up by my raspberry pi back\nthere i don't think it stopped i don't\nthink it stopped yet so thank you\nappreciate it everything is going to\nblow up\nno it's not going to blow up if it does\ni have automation in place to reboot it\nso\nthank you so much appreciate it",
          "metadata": {
            "og:site_name": "YouTube",
            "og:image:height": "720",
            "twitter:app:url:googleplay": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
            "position": "1",
            "twitter:app:name:ipad": "YouTube",
            "userInteractionCount": [
              "7589",
              "297254"
            ],
            "og:description": "I've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I...",
            "genre": "Science & Technology",
            "og:type": "video.other",
            "twitter:app:name:iphone": "YouTube",
            "requiresSubscription": "False",
            "og:video:height": "720",
            "al:ios:app_store_id": "544007664",
            "twitter:image": "https://i.ytimg.com/vi/h_GGd7HfKQ8/maxresdefault.jpg",
            "title": "Meet Grafana LOKI, a Log Aggregation System for EVERYTHING - YouTube",
            "og:image": "https://i.ytimg.com/vi/h_GGd7HfKQ8/maxresdefault.jpg",
            "twitter:player": "https://www.youtube.com/embed/h_GGd7HfKQ8",
            "twitter:player:height": "720",
            "og:video:tag": [
              "loki",
              "homelab",
              "home lab",
              "technotim",
              "techno tim",
              "prometheus for logs",
              "kubernetes",
              "docker",
              "syslog",
              "grafana loki",
              "promtail",
              "config",
              "self-hosted",
              "selfhosting",
              "logging",
              "logging server",
              "elk stack",
              "elk stack alternative",
              "kubernetes logs",
              "log all pods",
              "containers",
              "syslogging",
              "kubernetes cluster logging",
              "grafana",
              "grafana loki tutorial",
              "docker compose",
              "log all the things",
              "best logging system",
              "grafana loki dashboard",
              "grafana loki installation",
              "grafana loki kubernetes",
              "grafana loki vs elk"
            ],
            "twitter:app:id:iphone": "544007664",
            "al:android:url": "vnd.youtube://www.youtube.com/watch?v=h_GGd7HfKQ8&feature=applinks",
            "duration": "PT28M13S",
            "playerType": "HTML5 Flash",
            "og:video:width": "1280",
            "interactionType": [
              "https://schema.org/LikeAction",
              "https://schema.org/WatchAction"
            ],
            "al:ios:url": "vnd.youtube://www.youtube.com/watch?v=h_GGd7HfKQ8&feature=applinks",
            "viewport": [
              "width=device-width, initial-scale=1.0, viewport-fit=cover",
              "initial-scale=1, minimum-scale=1, width=device-width"
            ],
            "language": "en",
            "isFamilyFriendly": "true",
            "description": "I've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I..., I've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I...",
            "ogTitle": "Meet Grafana LOKI, a Log Aggregation System for EVERYTHING",
            "ogImage": "https://i.ytimg.com/vi/h_GGd7HfKQ8/maxresdefault.jpg",
            "og:title": "Meet Grafana LOKI, a Log Aggregation System for EVERYTHING",
            "og:image:width": "1280",
            "og:video:url": "https://www.youtube.com/embed/h_GGd7HfKQ8",
            "twitter:card": "player",
            "twitter:title": "Meet Grafana LOKI, a Log Aggregation System for EVERYTHING",
            "referrer": "origin-when-cross-origin",
            "og:video:type": "text/html",
            "apple-itunes-app": "app-id=544007664, app-argument=https://www.youtube.com/watch?v=h_GGd7HfKQ8&referring_app=com.apple.mobilesafari-smartbanner, affiliate-data=ct=smart_app_banner_polymer&pt=9008",
            "twitter:site": "@youtube",
            "twitter:url": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
            "twitter:app:url:iphone": "vnd.youtube://www.youtube.com/watch?v=h_GGd7HfKQ8&feature=applinks",
            "twitter:app:name:googleplay": "YouTube",
            "name": [
              "Meet Grafana LOKI, a Log Aggregation System for EVERYTHING",
              "Techno Tim"
            ],
            "height": [
              "720",
              "720"
            ],
            "datePublished": "2021-11-20T08:00:14-08:00",
            "og:video:secure_url": "https://www.youtube.com/embed/h_GGd7HfKQ8",
            "al:android:app_name": "YouTube",
            "ogSiteName": "YouTube",
            "uploadDate": "2021-11-20T08:00:14-08:00",
            "ogUrl": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
            "fb:app_id": "87741124305",
            "twitter:player:width": "1280",
            "al:android:package": "com.google.android.youtube",
            "twitter:app:url:ipad": "vnd.youtube://www.youtube.com/watch?v=h_GGd7HfKQ8&feature=applinks",
            "twitter:description": "I've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I...",
            "ogDescription": "I've been on a quest to find a new logging system.  I've use quite a few in the past, some open source, some proprietary, and some home grown, but recently I...",
            "al:ios:app_name": "YouTube",
            "al:web:url": "http://www.youtube.com/watch?v=h_GGd7HfKQ8&feature=applinks",
            "twitter:app:id:ipad": "544007664",
            "width": [
              "1280",
              "1280"
            ],
            "twitter:app:id:googleplay": "com.google.android.youtube",
            "og:url": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
            "identifier": "h_GGd7HfKQ8",
            "keywords": [
              "loki, homelab, home lab, technotim, techno tim, prometheus for logs, kubernetes, docker, syslog, grafana loki, promtail, config, self-hosted, selfhosting, logging, logging server, elk stack, elk stack alternative, kubernetes logs, log all pods, containers, syslogging, kubernetes cluster logging, grafana, grafana loki tutorial, docker compose, log all the things, best logging system, grafana loki dashboard, grafana loki installation, grafana loki kubernetes, grafana loki vs elk",
              "loki,homelab,home lab,technotim,techno tim,prometheus for logs,kubernetes,docker,syslog,grafana loki,promtail,config,self-hosted,selfhosting,logging,logging server,elk stack,elk stack alternative,kubernetes logs,log all pods,containers,syslogging,kubernetes cluster logging,grafana,grafana loki tutorial,docker compose,log all the things,best logging system,grafana loki dashboard,grafana loki installation,grafana loki kubernetes,grafana loki vs elk"
            ],
            "regionsAllowed": "AD,AE,AF,AG,AI,AL,AM,AO,AQ,AR,AS,AT,AU,AW,AX,AZ,BA,BB,BD,BE,BF,BG,BH,BI,BJ,BL,BM,BN,BO,BQ,BR,BS,BT,BV,BW,BY,BZ,CA,CC,CD,CF,CG,CH,CI,CK,CL,CM,CN,CO,CR,CU,CV,CW,CX,CY,CZ,DE,DJ,DK,DM,DO,DZ,EC,EE,EG,EH,ER,ES,ET,FI,FJ,FK,FM,FO,FR,GA,GB,GD,GE,GF,GG,GH,GI,GL,GM,GN,GP,GQ,GR,GS,GT,GU,GW,GY,HK,HM,HN,HR,HT,HU,ID,IE,IL,IM,IN,IO,IQ,IR,IS,IT,JE,JM,JO,JP,KE,KG,KH,KI,KM,KN,KP,KR,KW,KY,KZ,LA,LB,LC,LI,LK,LR,LS,LT,LU,LV,LY,MA,MC,MD,ME,MF,MG,MH,MK,ML,MM,MN,MO,MP,MQ,MR,MS,MT,MU,MV,MW,MX,MY,MZ,NA,NC,NE,NF,NG,NI,NL,NO,NP,NR,NU,NZ,OM,PA,PE,PF,PG,PH,PK,PL,PM,PN,PR,PS,PT,PW,PY,QA,RE,RO,RS,RU,RW,SA,SB,SC,SD,SE,SG,SH,SI,SJ,SK,SL,SM,SN,SO,SR,SS,ST,SV,SX,SY,SZ,TC,TD,TF,TG,TH,TJ,TK,TL,TM,TN,TO,TR,TT,TV,TW,TZ,UA,UG,UM,US,UY,UZ,VA,VC,VE,VG,VI,VN,VU,WF,WS,YE,YT,ZA,ZM,ZW",
            "theme-color": "rgba(255, 255, 255, 0.98)",
            "favicon": "https://www.youtube.com/s/desktop/dc4e66d7/img/favicon_32x32.png",
            "scrapeId": "01a0a962-e802-730d-becf-4b5e774b54eb",
            "sourceURL": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
            "url": "https://www.youtube.com/watch?v=h_GGd7HfKQ8",
            "statusCode": 200,
            "contentType": "text/html; charset=utf-8",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "postprocessorsUsed": [
              "youtube"
            ],
            "indexId": "f1836b58-159c-43ca-988c-c9f8cb32cbb7",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
          "title": "How Grafana Loki retention works",
          "description": "# [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n## post by dorinand on Jun 26, 2022\n```yaml\n\ncommon:\n  instance_interface_names:\n    - \"lo\"\n  path_prefix: /loki\n  storage:\n    filesystem:\n      chunks_directory: /loki/chunks\n      rules_directory: /loki/rules\n  replication_factor: 1\n  ring:\n    instance_interface_names:\n      - \"lo\"\n    kvstore:\n      store: inmemory\n\ncompactor:\n  working_directory: /loki/compactor\n  compaction_interval: 5m\n  retention_enabled: true\n  retention_delete_delay: 5m\n  delete_request_cancel_period: 1m\n\nlimits_config:\n  retention_period: 10m\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: boltdb-shipper\n      object_store: filesystem\n      schema: v11\n      index:\n        prefix: index_\n        period: 24h\n      chunks:\n        prefix: chunk_\n        period: 168h\n```\n\n## Closed on Apr 8, 2025\n### Related topics\n| Topic | Replies | Views | Activity |\n|-|-|-|-|\n| [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1) | 4.6k | [Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/7) |",
          "position": 6,
          "markdown": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/12) [Skip to top](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1)\n\n[Skip to main content](https://community.grafana.com/t/how-grafana-loki-retention-works/67754#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [How Grafana Loki retention works](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\n- [loki](https://community.grafana.com/tag/loki/14)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n\n[cancel selecting](https://community.grafana.com/t/how-grafana-loki-retention-works/67754)\n\n10.9k\nviews\n2\nlinks\n7\nusers\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/d/858c86/48.png)3](https://community.grafana.com/u/dorinand \"dorinand\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/48.png)2](https://community.grafana.com/u/renaudrenaud \"renaudrenaud\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/o/cab0a1/48.png)](https://community.grafana.com/u/ottovsky \"ottovsky\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/48.png)](https://community.grafana.com/u/ericleecnl996 \"ericleecnl996\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/48.png)](https://community.grafana.com/u/bojanflander \"bojanflander\")\n\n[Jun 2022](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/1 \"Jump to the first post\")\n\n1 / 11\n\n\nJun 2022\n\n\n[Apr 2024](https://community.grafana.com/t/how-grafana-loki-retention-works/67754/12)\n\n## post by dorinand on Jun 26, 2022\n\n[![](https://avatars.discourse-cdn.com/v4/letter/d/858c86/48.png)](https://community.grafana.com/u/dorinand)\n\n[dorinand](https://community.grafana.com/u/dorinand)\n\n1\n\n[Jun 2022](https://community.grafana.com/t/how-grafana-loki-retention-works/67754 \"Post date\")\n\nI would like to set up retention for logs stored in Grafana Loki and I am not sure how the retention really works. There is more period time to configure and from documentation, it is not so clear to understand how whole process of retention works.\n\nThis is my Loki configuration:\n\n```yaml\n\ncommon:\n  instance_interface_names:\n    - \"lo\"\n  path_prefix: /loki\n  storage:\n    filesystem:\n      chunks_directory: /loki/chunks\n      rules_directory: /loki/rules\n  replication_factor: 1\n  ring:\n    instance_interface_names:\n      - \"lo\"\n    kvstore:\n      store: inmemory\n\ncompactor:\n  working_directory: /loki/compactor\n  compaction_interval: 5m\n  retention_enabled: true\n  retention_delete_delay: 5m\n  delete_request_cancel_period: 1m\n\nlimits_config:\n  retention_period: 10m\n\nschema_config:\n  configs:\n    - from: 2020-10-24\n      store: boltdb-shipper\n      object_store: filesystem\n      schema: v11\n      index:\n        prefix: index_\n        period: 24h\n      chunks:\n        prefix: chunk_\n        period: 168h\n```\n\nCompactor should remove old data based on this configuration. This is how I understand config file:\n\n- `compactor.compaction_interval` \\- every 5 minutes is run compactor process\n- `compactor.retention_enabled` \\- enable to apply retention policy\n- `compactor.retention_delete_delay` \\- this is the time Compactor is waiting to delete chunks after `retention_period` exceed.\n- `compactor. delete_request_cancel_period` \\- allow cancellation of delete request made by API. I think, not used in my case at all.\n- `limits_config. retention_period` \\- this is time after which data should be deleted. According to doc - `The minimum retention period is 24h.`\n\nAccording to the configuration, I would expect to have logs for last 15 minutes:\n\n- **0:00** \\- first log arrives\n- **0:05** \\- compactor is running and because of retention 10 min, no logs are meant to be deleted\n- **0:10** \\- compactor is running again and because of retention 10 min, my first log should be assign for deletion. Because of retention delay 5min, it is still not deleted at this moment.\n- **0:15** \\- compactor is running for third time. From the second run, there has been log to be deleted and retention delay 5 min has expired, that means this log can be deleted now.\n\nThis is just an example of ideal time schedule. I understand there is async processes and timing is not so precise so lets say, according to my logic, this could be done in 30-40 minutes.\n\nI am running this configuration and I can see logs for last 2,5 hours:\n\n[![image](https://us1.discourse-cdn.com/grafana/original/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b.png)\\\\\nimage1344\u00d7206 6.89 KB](https://us1.discourse-cdn.com/grafana/original/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b.png \"image\")\n\nFirst log at **20:43** and last one ad **23:00**. This is quite long according to my estimation. I do not want to use it for this short period of time but how can I estimate log retention for example for 3 days, 1 week or 2 months?\n\n**Questions:**\n\n1. How is retention calculated and processed?\n2. Do I understand Loki configuration parameters properly?\n3. How does retention differs from `chunk.period` and `index.period` under `schema_config.config`?\n\n10.9k\nviews\n2\nlinks\n7\nusers\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/d/858c86/48.png)3](https://community.grafana.com/u/dorinand \"dorinand\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/48.png)2](https://community.grafana.com/u/renaudrenaud \"renaudrenaud\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/o/cab0a1/48.png)](https://community.grafana.com/u/ottovsky \"ottovsky\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/e/6de8d8/48.png)](https://community.grafana.com/u/ericleecnl996 \"ericleecnl996\")\n\n[![](https://avatars.discourse-cdn.com/v4/letter/b/5f8ce5/48.png)](https://community.grafana.com/u/bojanflander \"bojanflander\")\n\n5 months later\n\n\n## post by ottovsky on Dec 7, 2022\n\n11 days later\n\n\n## post by ericleecnl996 on Dec 19, 2022\n\n3 months later\n\n\n## post by bojanflander on Mar 30, 2023\n\n5 months later\n\n\n## post by renaudrenaud on Aug 31, 2023\n\n5 months later\n\n\n## post by arinovilyas on Jan 26, 2024\n\n## post by dorinand on Jan 27, 2024\n\n## post by dorinand on Jan 27, 2024\n\n## post by renaudrenaud on Jan 29, 2024\n\n2 months later\n\n\n## post by otakubowei on Apr 8, 2024\n\n1 year later\n\n\n## Closed on Apr 8, 2025\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-obs-stack-light-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-obs-stack-light)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [Loki does not delete logs after retention delete delay](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/1) | 4.6k | [Feb 2024](https://community.grafana.com/t/loki-does-not-delete-logs-after-retention-delete-delay/81898/7) |\n| [Loki retention isn\u2019t working as expected\u2014logs older than 24 hours are not getting deleted](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [3](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/1) | 549 | [Feb 2025](https://community.grafana.com/t/loki-retention-isnt-working-as-expected-logs-older-than-24-hours-are-not-getting-deleted/142440/4) |\n| [Loki log retention policy and period](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14),<br>- [retention](https://community.grafana.com/tag/retention/276) | [5](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/1) | 355 | [Dec 2025](https://community.grafana.com/t/loki-log-retention-policy-and-period/153531/6) |\n| [Log retention policy](https://community.grafana.com/t/log-retention-policy/116009)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14),<br>- [retention](https://community.grafana.com/tag/retention/276) | [4](https://community.grafana.com/t/log-retention-policy/116009/1) | 5.0k | [Mar 2024](https://community.grafana.com/t/log-retention-policy/116009/5) |\n| [Log retention configuration for loki is not working](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [6](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/1) | 4.4k | [Dec 2022](https://community.grafana.com/t/log-retention-configuration-for-loki-is-not-working/58935/7) |\n\nTopic list, column headers with buttons are sortable.",
          "metadata": {
            "twitter:description": "I would like to set up retention for logs stored in Grafana Loki and I am not sure how the retention really works. There is more period time to configure and from documentation, it is not so clear to understand how whole process of retention works.  This is my Loki configuration:  common:   instance_interface_names:     - \"lo\"   path_prefix: /loki   storage:     filesystem:       chunks_directory: /loki/chunks       rules_directory: /loki/rules   replication_factor: 1   ring:     instance_interf...",
            "color-scheme": "light",
            "ogSiteName": "Grafana Labs Community Forums",
            "language": "en",
            "google-site-verification": [
              "8aym1sTclxM_9RDJQ51QQucjfb8HYW2zCwUw3qjNkS8",
              "tDTNfz-2SQJ40TS5vbXHSzJOIXJkqRRxllNb4273uS4"
            ],
            "ogDescription": "I would like to set up retention for logs stored in Grafana Loki and I am not sure how the retention really works. There is more period time to configure and from documentation, it is not so clear to understand how whole process of retention works.  This is my Loki configuration:  common:   instance_interface_names:     - \"lo\"   path_prefix: /loki   storage:     filesystem:       chunks_directory: /loki/chunks       rules_directory: /loki/rules   replication_factor: 1   ring:     instance_interf...",
            "discourse_theme_id": "7",
            "ogTitle": "How Grafana Loki retention works - Grafana Loki - Grafana Labs Community Forums",
            "ogImage": "https://us1.discourse-cdn.com/grafana/optimized/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b_2_1024x156.png",
            "generator": "Discourse 2026.9.0-latest - https://github.com/discourse/discourse version 29c35dd9ebd12187abfa6cf3ebb3c8075c9989f5",
            "og:site_name": "Grafana Labs Community Forums",
            "twitter:url": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
            "publishedTime": "2022-06-26T21:15:45+00:00",
            "twitter:image": "https://us1.discourse-cdn.com/grafana/optimized/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b_2_1024x156.png",
            "og:description": "I would like to set up retention for logs stored in Grafana Loki and I am not sure how the retention really works. There is more period time to configure and from documentation, it is not so clear to understand how whole process of retention works.  This is my Loki configuration:  common:   instance_interface_names:     - \"lo\"   path_prefix: /loki   storage:     filesystem:       chunks_directory: /loki/chunks       rules_directory: /loki/rules   replication_factor: 1   ring:     instance_interf...",
            "og:image": "https://us1.discourse-cdn.com/grafana/optimized/3X/9/0/90a28be9c4c0365481a3efb2fae0ccc0702dd09b_2_1024x156.png",
            "description": "I would like to set up retention for logs stored in Grafana Loki and I am not sure how the retention really works. There is more period time to configure and from documentation, it is not so clear to understand how whole\u2026",
            "discourse_current_homepage": "categories",
            "og:title": "How Grafana Loki retention works - Grafana Loki - Grafana Labs Community Forums",
            "discourse/config/environment": "%7B%22modulePrefix%22%3A%22discourse%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22%22%2C%22locationType%22%3A%22history%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3Afalse%7D%2C%22APP%22%3A%7B%22name%22%3A%22discourse%22%2C%22version%22%3A%222026.9.0-latest%2029c35dd9ebd12187abfa6cf3ebb3c8075c9989f5%22%7D%7D",
            "article:published_time": "2022-06-26T21:15:45+00:00",
            "og:article:section": "Grafana Loki",
            "og:url": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
            "fragment": "!",
            "og:image:width": "1344",
            "ogUrl": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
            "og:type": "website",
            "og:ignore_canonical": "true",
            "viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content",
            "twitter:title": "How Grafana Loki retention works - Grafana Loki - Grafana Labs Community Forums",
            "theme-color": "#ffffff",
            "og:article:tag": "loki",
            "og:image:type": "image/png",
            "title": "How Grafana Loki retention works - Grafana Loki - Grafana Labs Community Forums",
            "discourse-track-view-session-id": "EMQ4aiJrzwHWHvLJMtB2FQPJ5yNMGBdM",
            "twitter:card": "summary",
            "og:article:section:color": "fb9d5a",
            "og:image:height": "206",
            "favicon": "https://us1.discourse-cdn.com/grafana/optimized/2X/2/27fb03d0906653283f7bc272584543da514529de_2_32x32.png",
            "scrapeId": "01a0a962-e802-730d-becf-4fd54b2152e0",
            "sourceURL": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
            "url": "https://community.grafana.com/t/how-grafana-loki-retention-works/67754",
            "statusCode": 200,
            "contentType": "text/html; charset=utf-8",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "4a8f146c-56d2-4d0e-9e5f-a1fed60ede23",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://grafana.com/docs/loki/latest/",
          "title": "Grafana Loki documentation",
          "description": "# Grafana Loki\n## Grafana Loki, frequently asked questions\n### Why isn\u2019t my log retention policy deleting old data?\n- `retention_enabled: true` must be set under the `compactor` block, not just in `limits_config`.\n\n```yaml\ncompactor:\n  working_directory: /data/loki/compactor\n  retention_enabled: true\n  delete_request_store: <your-object-store>\n\nlimits_config:\n  retention_period: 360h\n```",
          "position": 7,
          "markdown": "![ObservabilityCON 2025](https://a-us.storyblok.com/f/1022730/280x40/b0872b99f9/grafana-logo-observabilitycon-2025-black.svg/m/)\n\nWatch the keynote again and signup for more on-demand sessions.\n\n\n[Watch keynote](https://grafana.com/events/observabilitycon/?plcmt=obscon2025-post-event-banner)![](https://grafana.com/media/events/grafanacon/2025/icon-close-x.svg)\n\n![ObservabilityCON 2025](https://grafana.com/media/events/obscon/2025/grafana-obscon2025-promo-logo-black.svg)\n\n\ud83d\udce2 Registration + agenda now live\nExplore the latest Grafana Cloud and AI solutions, learn tips & tricks from demos and hands-on workshops, and get actionable advice to advance your observability strategy. Register now and get 50% off - limited tickets available (while they last!).\n\n\n[Register now](https://grafana.com/events/observabilitycon/?tech=target&plcmt=top-banner&aud=default)\n\nSearching...\n\nSite search\n\nAsk Grot AI\n\n[Try using ![Grot AI](https://grafana.com/static/img/grot-chat.svg)**Grot AI** for this query ->](https://grafana.com/grot/?chat=&from=/search)\n\nAll\n\nDocs\n\nView all results\n\nNo results.\n\nThere was an error with your request.\n\n> Documentation for automated readers\n>\n> A curated documentation index is available at: https://grafana.com/llms.txt\n>\n> A complete documentation index is available at: https://grafana.com/llms-full.txt\n>\n> These indexes can help with page discovery before fetching individual documents.\n\nThis page is also available in Markdown, which may be easier for automated readers\nand AI tools to parse than HTML. The Markdown version is available at\nhttps://grafana.com/docs/loki/latest.md, or by sending\nAccept: text/markdown to https://grafana.com/docs/loki/latest/. For broader\ndocumentation discovery, the curated index is available at https://grafana.com/llms.txt\nand the complete index is available at https://grafana.com/llms-full.txt.\n\nGrafana Loki\n\n[Documentation](https://grafana.com/docs/)![breadcrumb arrow](https://grafana.com/static/assets/img/icons/grafana-icon-breadcrumb-arrow-gray.svg)Grafana Loki\n\nOpen source\n\n![Grafana Loki](https://grafana.com/media/docs/loki/logo-grafana-loki.png)\n\n# Grafana Loki\n\nGrafana Loki is a set of open source components that can be composed into a fully featured logging stack. A small index and highly compressed chunks simplifies the operation and significantly lowers the cost of Loki.\n\n* * *\n\n## Overview\n\nUnlike other logging systems, Loki is built around the idea of only indexing metadata about your logs\u2019 labels (just like Prometheus labels).\nLog data itself is then compressed and stored in chunks in object stores such as Amazon Simple Storage Service (S3) or Google Cloud Storage (GCS), or even locally on the filesystem.\n\n## Explore\n\n[Learn about Loki\\\\\n\\\\\nLearn about the Loki architecture and components, the various deployment modes, and best practices for labels.](https://grafana.com/docs/loki/latest/get-started/) [Set up Loki\\\\\n\\\\\nView instructions for how to configure and install Loki, migrate from previous deployments, and upgrade your Loki environment.](https://grafana.com/docs/loki/latest/setup/) [Configure Loki\\\\\n\\\\\nView the Loki configuration reference and configuration examples.](https://grafana.com/docs/loki/latest/configure/) [Send logs to Loki\\\\\n\\\\\nSelect one or more clients to use to send your logs to Loki.](https://grafana.com/docs/loki/latest/send-data/) [Manage Loki\\\\\n\\\\\nLearn how to manage tenants, log ingestion, storage, queries, and more.](https://grafana.com/docs/loki/latest/operations/) [Query with LogQL\\\\\n\\\\\nInspired by PromQL, LogQL is Grafana Loki\u2019s query language. LogQL uses labels and operators for filtering.](https://grafana.com/docs/loki/latest/query/)\n\n## Grafana Loki, frequently asked questions\n\nHere are answers to some frequently asked questions about how to configure and run Loki.\n\n### Where should I start if I\u2019m new to Loki?\n\nStart with the [Loki Tutorial](https://grafana.com/docs/loki/latest/get-started/), which walks you through what Loki is, how it works, and how the components fit together.\n\n- **Try it locally.** The fastest way to experiment is to run Loki in [monolithic (single-binary) mode](https://grafana.com/docs/loki/latest/setup/install/) with a local filesystem backend and send logs to it with [Grafana Alloy](https://grafana.com/docs/alloy/latest/).\n- **Understand labels.** Loki\u2019s indexing model is label-based, which is different from most logging systems. Read [Labels](https://grafana.com/docs/loki/latest/get-started/labels/) and the [label best practices](https://grafana.com/docs/loki/latest/get-started/labels/bp-labels/) early \u2014 how you label your logs directly affects query performance and storage costs.\n- **Learn LogQL.** [LogQL](https://grafana.com/docs/loki/latest/query/) is Loki\u2019s query language. Start with simple label matchers and line filters, then explore log pipeline stages and metric queries as you need them.\n- **Explore with Grafana.** Connect Loki as a [data source in Grafana](https://grafana.com/docs/grafana/latest/datasources/loki/) and use [Explore](https://grafana.com/docs/grafana/latest/explore/) to run ad-hoc queries against your logs.\n\nThe [Grafana Labs Learning Hub](https://grafana.com/docs/learning-hub/) offers self-paced, hands-on courses relevant to Loki:\n\n- **[Send logs to Grafana Cloud using Alloy](https://grafana.com/docs/learning-hub/)** \u2014 Walk through configuring Grafana Alloy to ship logs to Loki in Grafana Cloud.\n- **[Send data from external collectors](https://grafana.com/docs/learning-hub/)** \u2014 Learn how to send logs to Loki using OpenTelemetry (OTLP) or the HTTP API, and choose the right method for your setup.\n- **[Explore your infrastructure data with Grafana Drilldown apps](https://grafana.com/docs/learning-hub/)** \u2014 Explore Loki logs visually without writing LogQL, using the Logs Drilldown app to filter by labels, detect patterns, and investigate errors.\n- **[Optimize Adaptive Logs](https://grafana.com/docs/learning-hub/)** \u2014 Reduce log volume and storage costs in Grafana Cloud by tuning which logs Loki ingests.\n\n### Should I self-host or use Grafana Cloud for logs?\n\nThe right answer depends on your team\u2019s capacity and priorities.\nChoose Grafana Cloud if you want to get up and running quickly, prefer not to manage infrastructure, or are a small team without dedicated operations resources. The free tier is generous enough for most individuals and small projects.\n\nChoose self-hosted OSS or Enterprise if you have strict data residency or compliance requirements, need to keep all data on your own infrastructure, or have an existing investment in self-managed tooling like Prometheus and want to extend it.\n\nThe feature set between Cloud and a self-managed Enterprise stack is broadly equivalent. The primary difference is operational overhead: self-hosting means you own the availability, scaling, and maintenance of every component in the stack.\n\n### What are the best practices for Loki labels vs. structured metadata?\n\nLoki\u2019s indexing model differs significantly from other observability products. Choosing the wrong fields as labels is the most common cause of poor query performance and high resource usage.\n\n**Labels** define a log stream. Every unique combination of label values creates a new stream, which is stored and indexed separately.\n\n- \u2705 Use labels for **low-cardinality** dimensions you will always filter on: `env`, `cluster`, `namespace`, `app`, `job`.\n- \u274c Do not use labels for **high-cardinality** values: pod, instance IDs, request IDs, user IDs, trace IDs, HTTP status codes, IP addresses. Each unique value creates a new stream, causing \u201ccardinality explosion\u201d that degrades ingestion and query performance.\n\n**Structured metadata** (introduced in Loki 3.0) allows attaching key-value pairs to log entries without creating new streams. Use it for values you want to filter or display but that are too high-cardinality for labels:\n\nAlloy![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```alloy\n// Example: attaching trace_id as structured metadata via Alloy\nloki.process \"default\" {\n  stage.json {\n    expressions = { \"trace_id\" = \"\" }\n  }\n\n  stage.structured_metadata {\n    values = { \"trace_id\" = \"\" }\n  }\n\n  forward_to = [loki.write.local.receiver]\n}\n\nloki.write \"local\" {\n  endpoint {\n    url = \"http://loki:3100/loki/api/v1/push\"\n  }\n}\n```\n\n**Parsed fields** (extracted at query time with `| json`, `| logfmt`, `| pattern`, `| regexp`) require no schema changes and add no indexing overhead. Prefer them for ad-hoc filtering on log content.\n\n**Rule of thumb:** If you would filter by it in _every_ query, it belongs in a label. If you only need it occasionally or it has many unique values, use structured metadata or parse it from the log line at query time.\n\n### Why does `service_name` show as `unknown_service` in Explore Logs?\n\nLoki\u2019s Explore Logs feature uses a `service_name` label to group and navigate logs. If it shows `unknown_service`, Loki could not automatically determine a service name from the incoming stream.\n\nIf a `service_name` label is already present on the stream, Loki uses it directly. Otherwise, Loki\u2019s `discover_service_name` feature looks for the first non-empty value from these label keys, in order:\n\n- service\n- app\n- application\n- app\\_name\n- name\n- app\\_kubernetes\\_io\\_name\n- container\n- container\\_name\n- k8s\\_container\\_name\n- component\n- workload\n- job\n- k8s\\_job\\_name\n\n**Common causes:**\n\n- The log shipper (Alloy, OTel Collector, kube-logging-operator) is not forwarding Kubernetes metadata as stream labels.\n- The label name uses dot notation (`service.name`). Loki normalizes label names server-side, replacing dots with underscores (for example, `service.name` becomes `service_name`).\n- `discover_service_name` is disabled in your Loki configuration.\n\n**Verify by checking your stream labels** in Explore. If none of the above keys are present as labels, configure your log shipper to include them. For Alloy, ensure `loki.source.kubernetes` or `discovery.kubernetes` is passing through pod metadata.\n\nYou can customize the list of labels Loki checks by setting `discover_service_name` in `limits_config`.\n\n### How do I fix \u201cingestion rate limit exceeded\u201d (HTTP 429) errors?\n\nA 429 error from Loki means an ingestion rate limit has been hit. Loki enforces limits both globally and per-stream.\n\n**Global ingestion limits** (applied per tenant):\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nlimits_config:\n  ingestion_rate_mb: 16        # default: 4 MB/s\n  ingestion_burst_size_mb: 32  # default: 6 MB\n```\n\n**Per-stream rate limit:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nlimits_config:\n  per_stream_rate_limit: 5MB        # default: 3MB\n  per_stream_rate_limit_burst: 15MB # default: 15MB (5x the rate limit)\n```\n\n**To identify which streams are responsible**, check the error message in your log shipper. It includes the stream labels of the offending stream. You can also query Loki\u2019s metrics endpoint for `loki_ingester_streams_created_total` broken down by tenant.\n\nIf you are self-hosting and consistently hitting limits with legitimate log volume, increase the values above in `limits_config`. If you are on Grafana Cloud, contact support to adjust your plan limits.\n\n> Note\n>\n> Increasing limits without investigating root cause can mask runaway log producers. Always check whether a specific workload or namespace is generating an unexpected spike before raising limits.\n\n### Why can\u2019t Grafana connect to Loki when both are running in Docker?\n\nWhen Grafana and Loki run as separate Docker containers, `localhost` inside the Grafana container refers to the Grafana container itself, not the host machine or the Loki container. This is the most common misconfiguration for new users.\n\n**Correct datasource URL in Docker Compose:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\n# docker-compose.yml\nservices:\n  loki:\n    image: grafana/loki:latest\n    ports:\n      - \"3100:3100\"\n\n  grafana:\n    image: grafana/grafana:latest\n    environment:\n      - GF_DATASOURCES_DEFAULT_URL=http://loki:3100\n```\n\nIn Grafana\u2019s datasource settings, use `http://loki:3100` (the Docker Compose service name) instead of `http://localhost:3100`.\n\n**For Kubernetes deployments**, use the in-cluster service DNS name:\n\n![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```none\nhttp://loki.monitoring.svc.cluster.local:3100\n```\n\n**Verify connectivity** by exec-ing into the Grafana container and running:\n\nBash![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```bash\ncurl http://loki:3100/ready\n```\n\nIf this returns `ready`, the networking is correct and the issue lies in the Grafana datasource configuration itself.\n\n### What causes \u201cToo many outstanding requests\u201d errors on my dashboard?\n\nThis error occurs when the number of concurrent queries to Loki exceeds the configured limit for a tenant. It is most common when a dashboard has four or more panels querying over a long time range against a single-node (monolithic) deployment.\n\n**Key configuration knobs:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\nquery_scheduler:\n  max_outstanding_requests_per_tenant: 32000  # default: 32000\n\nfrontend:\n  max_outstanding_per_tenant: 2048            # default: 2048\n\nlimits_config:\n  split_queries_by_interval: 24h              # default: 1h\n```\n\nSplitting queries by interval reduces the load per request by breaking large time-range queries into smaller parallel chunks. For single-node deployments under sustained dashboard load, also consider increasing chunk sizes to reduce the total number of chunk reads:\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\ningester:\n  chunk_target_size: 1572864\n  max_chunk_age: 2h\n  chunk_idle_period: 30m\n```\n\nIf the issue persists at scale, consider moving from a monolithic deployment to [microservices](https://grafana.com/docs/loki/latest/get-started/deployment-modes/) mode.\n\n### How do I make a LogQL query return zero instead of \u201cno data\u201d?\n\nBy default, LogQL metric queries return no data points for intervals where no log lines matched, rather than returning `0`. This breaks percentage calculations and alert rules that expect a numeric baseline.\n\n**Workaround using `or on() vector(0)`** (mirrors the PromQL pattern):\n\nlogql![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```logql\n(\n  sum(count_over_time({app=\"my-app\"} |= \"error\" [5m]))\n  or on() vector(0)\n)\n```\n\n**For ratio/percentage queries**, guard the denominator with `> 0` to avoid dividing by zero (which produces `NaN`), and wrap the entire expression with `or on() vector(0)` so quiet periods return `0` instead of no data:\n\nlogql![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```logql\n(\n  (\n    sum(count_over_time({app=\"my-app\"} | json | status=~\"5..\" [5m]))\n    or on() vector(0)\n  )\n  /\n  (\n    sum(count_over_time({app=\"my-app\"} [5m]))\n    > 0\n  )\n)\nor on() vector(0)\n```\n\n**For alerting**, this pattern is essential. Without it, an alert rule using `count_over_time` produces no evaluation result (not `0`) during quiet periods, which can cause alerts to flap or never resolve correctly.\n\n### Why isn\u2019t my log retention policy deleting old data?\n\nRetention in Loki is handled by the **Compactor**, not by the ingester or storage backend directly. A few common reasons why old data persists even after configuring a retention period:\n\n- `retention_enabled: true` must be set under the `compactor` block, not just in `limits_config`.\n- The Compactor must be running. In monolithic deployments it is sometimes inadvertently disabled.\n- Deletion is not immediate. The Compactor runs on a schedule and only marks chunks for deletion after a configurable grace period (`retention_delete_delay`).\n- When using filesystem storage, the chunks directory size may not visibly decrease right away. The Compactor marks files for deletion first, then removes them on subsequent runs.\n\n**Minimum required configuration:**\n\nYAML![Copy code to clipboard](https://grafana.com/media/images/icons/icon-copy-small-2.svg)Copy\n\n```yaml\ncompactor:\n  working_directory: /data/loki/compactor\n  retention_enabled: true\n  delete_request_store: <your-object-store>\n\nlimits_config:\n  retention_period: 360h\n```\n\nTo verify the Compactor is running and retention is active, check the Loki logs for lines referencing `compactor` and look for the metrics `loki_boltdb_shipper_compact_tables_operation_total` (compaction runs) and `loki_compactor_apply_retention_operation_total` (retention runs).\n\n## Was this page helpful?\n\n![\ud83d\udc4d](https://grafana.com/media/images/svg/thumbs-up.svg) Yes![\ud83d\udc4e](https://grafana.com/media/images/svg/thumbs-up.svg) No\n\n[Suggest an edit in GitHub](https://github.com/grafana/loki/edit/release-3.7.x/docs/sources/_index.md) [Create a GitHub issue](https://github.com/grafana/loki/issues/new?title=Documentation%20feedback:%20/docs/sources/_index.md) [Email docs@grafana.com](mailto:docs@grafana.com) [Help and support](https://grafana.com/help/) [Community](https://grafana.com/community/)\n\n## Related resources from Grafana Labs\n\nAdditional helpful documentation, links, and articles:\n\n[![webinar icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-webinar.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Getting started with logging and Grafana Loki](https://grafana.com/static/assets/featured/getting-started-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nGetting started with logging and Grafana Loki\\\\\n\\\\\nSee a demo of the updated features in Loki, and how to create metrics from logs and alert on your logs with powerful Prometheus-style alerting rules.](https://grafana.com/go/webinar/getting-started-with-logging-and-grafana-loki/?pg=docs-loki-latest&plcmt=related) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Essential Grafana Loki configuration settings](https://grafana.com/static/assets/featured/logging-with-loki-essential-configuration-settings_featured.png?w=400)\\\\\n\\\\\nEssential Grafana Loki configuration settings\\\\\n\\\\\nThis webinar focuses on Grafana Loki configuration including agents Promtail and Docker; the Loki server; and Loki storage for popular backends.](https://grafana.com/go/webinar/logging-with-loki-essential-configuration-settings/?pg=docs-loki-latest&plcmt=related-2) [![video icon](https://grafana.com/static/assets/img/icons/grafana-icon-card-video.svg)\\\\\n\\\\\nVideo\\\\\n\\\\\n![Scaling and securing your logs with Grafana Loki](https://grafana.com/static/assets/featured/scaling-and-securing-your-logs-with-grafana-loki_featured.png?w=400)\\\\\n\\\\\nScaling and securing your logs with Grafana Loki\\\\\n\\\\\nThis webinar covers the challenges of scaling and securing logs, and how Grafana Cloud Logs powered by Grafana Loki can help, cost-effectively.](https://grafana.com/go/webinar/scaling-and-securing-your-logs-with-grafana-loki/?pg=docs-loki-latest&plcmt=related-3)\n\nAsk Grafana Assistant",
          "metadata": {
            "facebook-domain-verification": "0nzzvug74mf2l7egl1acd75hg8l0zq",
            "twitter:description": "Grafana Loki is a set of open source components that can be composed into a fully featured logging stack.",
            "viewport": "width=device-width,initial-scale=1,maximum-scale=1",
            "zd-site-verification": "khfhpajsuhgh7m48qdm8f9",
            "language": "en",
            "ogTitle": "\n  Grafana Loki | Grafana Loki documentation\n\n\n",
            "ogImage": "https://grafana.com/meta-generator/Grafana+Loki@@@loki@@@9.png",
            "twitter:image": "https://grafana.com/meta-generator/Grafana+Loki@@@loki@@@9.png",
            "twitter:site": "@grafana",
            "og:image:width": "1200",
            "twitter:url": "https://twitter.com/grafana",
            "og:title": "\n  Grafana Loki | Grafana Loki documentation\n\n\n",
            "og:image": "https://grafana.com/meta-generator/Grafana+Loki@@@loki@@@9.png",
            "twitter:card": "summary_large_image",
            "Copyright": "Grafana Labs",
            "robots": "index, follow",
            "og:site_name": "Grafana Labs",
            "og:type": "website",
            "og:description": "Grafana Loki is a set of open source components that can be composed into a fully featured logging stack.",
            "application-name": "Grafana Labs",
            "og:image:height": "630",
            "ogSiteName": "Grafana Labs",
            "description": "Grafana Loki is a set of open source components that can be composed into a fully featured logging stack.",
            "twitter:title": "\n  Grafana Loki | Grafana Loki documentation\n\n\n",
            "title": "Grafana Loki | Grafana Loki documentation\n",
            "favicon": "https://grafana.com/static/assets/img/fav32.png",
            "scrapeId": "01a0a962-e802-730d-becf-518fdbc59c61",
            "sourceURL": "https://grafana.com/docs/loki/latest/",
            "url": "https://grafana.com/docs/loki/latest/",
            "statusCode": 200,
            "contentType": "text/html",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "9ea6eade-565b-4a59-b6fc-d233e89cc18c",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
          "title": "LOKI Retention Policy and Chunk Deletion Issue",
          "description": "# [LOKI Retention Policy and Chunk Deletion Issue](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n## post by rohiniraman12 on Nov 3, 2025\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057#p-291697-questions-3)**Questions**\nretention_enabled: true",
          "position": 8,
          "markdown": "[![Grafana Labs](https://grafana.com/static/assets/internal/grafana_logo-web-dark.svg)](https://grafana.com/?pg=community&plcmt=topnav)\n\n[Skip to last reply](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/3) [Skip to top](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/1)\n\n[Skip to main content](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057#main-container)\n\n\u200b\n\n\nCheck [Grafana events](https://community.grafana.com/t/grafana-community-events-in-september/164356) next to you this September ![:smiling_face_with_sunglasses:](https://emoji.discourse-cdn.com/twitter/smiling_face_with_sunglasses.png?v=15)\n\nFrom Austin to London to Kenya to Nagpur - 27 locations, 27 opportunities to meet the community ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=15)\n\n# [LOKI Retention Policy and Chunk Deletion Issue](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n\n[Grafana Loki](https://community.grafana.com/c/grafana-loki/41)\n\nYou have selected **0** posts.\n\n[select all](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n\n[cancel selecting](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057)\n\n[Nov 2025](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/1 \"Jump to the first post\")\n\n1 / 3\n\n\nNov 2025\n\n\n[Nov 2025](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057/3)\n\n## post by rohiniraman12 on Nov 3, 2025\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/48.png)](https://community.grafana.com/u/rohiniraman12)\n\n[rohiniraman12](https://community.grafana.com/u/rohiniraman12)\n\n[Nov 2025](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057 \"Post date\")\n\nHey everyone\n\nWe\u2019re running into an issue with our on-prem **Loki setup (not on Kubernetes)** and wanted to see if anyone else has faced something similar or has ideas on how to fix it.\n\n* * *\n\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057\\#p-291697-our-setup-1)**Our Setup**\n\n- **Cluster:** 2-node Loki setup (Ingestor / Distributor / Querier roles)\n\n- **Promtail:** Managed by our DevOps team (runs as a DaemonSet \u2014 we don\u2019t have admin access, so a bit of dependency there)\n\n- **Storage:** Everything is on local filesystem mounts:\n\n\n```bash\n\n/data/loki/wal\n/data/loki/chunks\n/data/loki/index\n```\n\n- **Retention:** Configured in `loki-config.yaml` for **5 days**\n  - We\u2019ve tuned parameters like chunk block size (2 MB) to optimize space usage\n- **Deletion API:** We\u2019ve also tried using the `curl` deletion API, but understand it only _marks_ data for deletion in the index \u2014 it doesn\u2019t immediately remove chunk files.\n\n\n* * *\n\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057\\#p-291697-what-were-observing-2)**What We\u2019re Observing**\n\n1. **Chunk file timestamps keep changing**\n\n\nEven old chunk files under `/data/loki/chunks` keep getting their \u201cmodified date\u201d updated.\n\n\nWhen we check with:\n\n\n```bash\n\nls -ltrh /data/loki/chunks\n```\n\n\nwe can see the modification dates changing regularly, even for files that should be past retention.\n\n2. **Retention logic not kicking in**\n\n\nWe wrote a small custom cleanup script to delete chunks older than 5 days, but since the modified date keeps updating, nothing ever qualifies for deletion.\n\n3. **Disk usage keeps going up**\n\n\nDespite retention being set to 5 days (and even after testing the deletion API), the `/data/loki/chunks` folder size keeps increasing.\n\n\nIt doesn\u2019t seem like the old data is actually being removed.\n\n\n* * *\n\n### [Heading link](https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057\\#p-291697-questions-3)**Questions**\n\n- Why would Loki be updating chunk file modification timestamps?\n\n- How can we make sure chunks are _actually_ deleted after retention (and not just marked)?\n\n- Is there a better approach to enforce retention-based cleanup when running Loki on filesystem storage \u2014 not in Kubernetes and not using object storage?\n\n- Could something like WAL replay or a background process (e.g. compactor) be touching those files and resetting timestamps?\n\n**loki version 2.9.3**\n\n**loki yaml:**\n\n\ningester:\n\n\nlifecycler:\n\n\nring:\n\n\nkvstore:\n\n\nstore: memberlist\n\n\nreplication\\_factor: 1\n\n\nfinal\\_sleep: 0s\n\n\nchunk\\_idle\\_period: 5m\n\n\nchunk\\_retain\\_period: 30s\n\n\nmax\\_transfer\\_retries: 0\n\n\nchunk\\_block\\_size: 2097152\n\n\nchunk\\_encoding: snappy\n\n\nmax\\_chunk\\_age: 2h\n\ndistributor:\n\n\nring:\n\n\nkvstore:\n\n\nstore: memberlist\n\nquerier:\n\n\nengine:\n\n\ntimeout: 1m\n\n\nquery\\_ingesters\\_within: 2h\n\nquery\\_range:\n\n\nalign\\_queries\\_with\\_step: true\n\n\nmax\\_retries: 5\n\n\nparallelise\\_shardable\\_queries: true\n\nfrontend:\n\n\nlog\\_queries\\_longer\\_than: 5s\n\n\ncompress\\_responses: true\n\nfrontend\\_worker:\n\n\nfrontend\\_address: X.X.X.X\n\nschema\\_config:\n\n\nconfigs:\n\n\n\\- from: 2020-10-24\n\n\nstore: boltdb-shipper\n\n\nobject\\_store: filesystem\n\n\nschema: v11\n\n\nindex:\n\n\nprefix: index\\_\n\n\nperiod: 24h\n\nstorage\\_config:\n\n\nboltdb\\_shipper:\n\n\nactive\\_index\\_directory: /data/loki/index\n\n\ncache\\_location: /data/loki/index\\_cache\n\n\nshared\\_store: filesystem\n\nfilesystem:\n\n\ndirectory: /data/loki/chunks\n\ncompactor:\n\n\nworking\\_directory: /data/loki/compactor\n\n\nshared\\_store: filesystem\n\n\nretention\\_enabled: true\n\n\ndelete\\_request\\_cancel\\_period: 1m\n\n\ndeletion\\_mode: filter-and-delete\n\nlimits\\_config:\n\n\ningestion\\_burst\\_size\\_mb: 500\n\n\ningestion\\_rate\\_mb: 1024\n\n\ningestion\\_rate\\_strategy: global\n\n\nmax\\_cache\\_freshness\\_per\\_query: 10m\n\n\nmax\\_global\\_streams\\_per\\_user: 50000\n\n\nmax\\_query\\_parallelism: 128\n\n\nper\\_stream\\_rate\\_limit: 500MB\n\n\nper\\_stream\\_rate\\_limit\\_burst: 500MB\n\n\nreject\\_old\\_samples: true\n\n\nreject\\_old\\_samples\\_max\\_age: 120h\n\n\nretention\\_period: 5d\n\n\nsplit\\_queries\\_by\\_interval: 15m\n\n\nenforce\\_metric\\_name: false\n\n\nmax\\_entries\\_limit\\_per\\_query: 80000\n\n\nallow\\_deletes: true\n\nchunk\\_store\\_config:\n\n\nmax\\_look\\_back\\_period: 0s\n\ntable\\_manager:\n\n\nretention\\_deletes\\_enabled: true\n\n\nretention\\_period: 5d\n\n**curl api:**\n\n\ncurl -X DELETE \u201chttp://<loki\\_host>:3100/loki/api/v1/delete\u201d\n\n\n  -H \u201cX-Scope-OrgID: <tenant\\_id>\u201d\n\n\n\u2013data-urlencode \u2018query={job=\u201cvarlogs\u201d} \\|~ \u201csensitive\\_data\u201d\u2019\n\n\n\u2013data-urlencode \u2018start=<start\\_timestamp>\u2019\n\n\n\u2013data-urlencode \u2018end=<end\\_timestamp>\u2019\n\nIf anyone has seen this behavior or has tips on how to manage chunk cleanup and ensure retention works effectively in a non-K8s setup, please share your thoughts.\n\n\nThanks in advance!\n\n\n280\nviews\n\n\n[![](https://avatars.discourse-cdn.com/v4/letter/r/e9a140/48.png)2](https://community.grafana.com/u/rohiniraman12 \"rohiniraman12\")\n\n[![](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/48/22401_2.png)](https://community.grafana.com/u/tonyswumac \"tonyswumac\")\n\n## post by tonyswumac on Nov 3, 2025\n\n## post by rohiniraman12 on Nov 5, 2025\n\n### This topic will close a year after the last reply.\n\nReply\n\n[![](https://grafana.com/static/img/community-ads/grafana-cloud-get-started-light-2x_commad.png)](https://grafana.com/auth/sign-up/create-user?pg=community&plcmt=post&cta=img-get-started-light)\n\n### Related topics\n\n| Topic | Replies | Views | Activity |\n| --- | --- | --- | --- |\n| [Filesystem retention not working](https://community.grafana.com/t/filesystem-retention-not-working/58192)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) | [5](https://community.grafana.com/t/filesystem-retention-not-working/58192/1) | 3.9k | [Apr 2024](https://community.grafana.com/t/filesystem-retention-not-working/58192/6) |\n| [Loki chunks deletion](https://community.grafana.com/t/loki-chunks-deletion/21196)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [loki](https://community.grafana.com/tag/loki/14) | [4](https://community.grafana.com/t/loki-chunks-deletion/21196/1) | 5.9k | [Dec 2024](https://community.grafana.com/t/loki-chunks-deletion/21196/5) |\n| [Loki retention: chunks kinda deleted, but the size of the folder didn\u2019t decrease](https://community.grafana.com/t/loki-retention-chunks-kinda-deleted-but-the-size-of-the-folder-didnt-decrease/159758)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) <br>- [retention](https://community.grafana.com/tag/retention/276) | [2](https://community.grafana.com/t/loki-retention-chunks-kinda-deleted-but-the-size-of-the-folder-didnt-decrease/159758/1) | 109 | [Dec 2025](https://community.grafana.com/t/loki-retention-chunks-kinda-deleted-but-the-size-of-the-folder-didnt-decrease/159758/3) |\n| [Loki disk space inflation](https://community.grafana.com/t/loki-disk-space-inflation/109287)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) | [10](https://community.grafana.com/t/loki-disk-space-inflation/109287/1) | 3.2k | [Jun 2024](https://community.grafana.com/t/loki-disk-space-inflation/109287/11) |\n| [Loki - helm simple stack : retention is not working](https://community.grafana.com/t/loki-helm-simple-stack-retention-is-not-working/122775)<br>[Grafana Loki](https://community.grafana.com/c/grafana-loki/41) | [1](https://community.grafana.com/t/loki-helm-simple-stack-retention-is-not-working/122775/1) | 667 | [May 2024](https://community.grafana.com/t/loki-helm-simple-stack-retention-is-not-working/122775/2) |\n\nTopic list, column headers with buttons are sortable.",
          "metadata": {
            "ogTitle": "LOKI Retention Policy and Chunk Deletion Issue - Grafana Loki - Grafana Labs Community Forums",
            "publishedTime": "2025-11-03T11:49:48+00:00",
            "google-site-verification": [
              "8aym1sTclxM_9RDJQ51QQucjfb8HYW2zCwUw3qjNkS8",
              "tDTNfz-2SQJ40TS5vbXHSzJOIXJkqRRxllNb4273uS4"
            ],
            "discourse-track-view-session-id": "XCw9VrXObtZwq7gJJdp6DPY6tCVDIMRV",
            "og:image": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "og:url": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
            "og:ignore_canonical": "true",
            "ogUrl": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
            "theme-color": "#ffffff",
            "title": "LOKI Retention Policy and Chunk Deletion Issue - Grafana Loki - Grafana Labs Community Forums",
            "ogSiteName": "Grafana Labs Community Forums",
            "discourse_theme_id": "7",
            "ogImage": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "twitter:card": "summary",
            "description": "Hey everyone \nWe\u2019re running into an issue with our on-prem Loki setup (not on Kubernetes) and wanted to see if anyone else has faced something similar or has ideas on how to fix it. \n\nOur Setup\n\n\nCluster: 2-node Loki set\u2026",
            "ogDescription": "Hey everyone  We\u2019re running into an issue with our on-prem Loki setup (not on Kubernetes) and wanted to see if anyone else has faced something similar or has ideas on how to fix it.   Our Setup   Cluster: 2-node Loki setup (Ingestor / Distributor / Querier roles)    Promtail: Managed by our DevOps team (runs as a DaemonSet \u2014 we don\u2019t have admin access, so a bit of dependency there)    Storage: Everything is on local filesystem mounts:  /data/loki/wal   /data/loki/chunks   /data/loki/index     Re...",
            "og:type": "website",
            "og:article:section": "Grafana Loki",
            "og:article:section:color": "fb9d5a",
            "og:description": "Hey everyone  We\u2019re running into an issue with our on-prem Loki setup (not on Kubernetes) and wanted to see if anyone else has faced something similar or has ideas on how to fix it.   Our Setup   Cluster: 2-node Loki setup (Ingestor / Distributor / Querier roles)    Promtail: Managed by our DevOps team (runs as a DaemonSet \u2014 we don\u2019t have admin access, so a bit of dependency there)    Storage: Everything is on local filesystem mounts:  /data/loki/wal   /data/loki/chunks   /data/loki/index     Re...",
            "og:title": "LOKI Retention Policy and Chunk Deletion Issue - Grafana Loki - Grafana Labs Community Forums",
            "discourse_current_homepage": "categories",
            "viewport": "width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover, interactive-widget=resizes-content",
            "fragment": "!",
            "og:site_name": "Grafana Labs Community Forums",
            "twitter:image": "https://us1.discourse-cdn.com/grafana/original/2X/a/a7f38198d3aa26d70bae13c3379e5b93a010e7d7.png",
            "twitter:title": "LOKI Retention Policy and Chunk Deletion Issue - Grafana Loki - Grafana Labs Community Forums",
            "language": "en",
            "color-scheme": "light",
            "twitter:description": "Hey everyone  We\u2019re running into an issue with our on-prem Loki setup (not on Kubernetes) and wanted to see if anyone else has faced something similar or has ideas on how to fix it.   Our Setup   Cluster: 2-node Loki setup (Ingestor / Distributor / Querier roles)    Promtail: Managed by our DevOps team (runs as a DaemonSet \u2014 we don\u2019t have admin access, so a bit of dependency there)    Storage: Everything is on local filesystem mounts:  /data/loki/wal   /data/loki/chunks   /data/loki/index     Re...",
            "article:published_time": "2025-11-03T11:49:48+00:00",
            "generator": "Discourse 2026.9.0-latest - https://github.com/discourse/discourse version 29c35dd9ebd12187abfa6cf3ebb3c8075c9989f5",
            "discourse/config/environment": "%7B%22modulePrefix%22%3A%22discourse%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22%22%2C%22locationType%22%3A%22history%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3Afalse%7D%2C%22APP%22%3A%7B%22name%22%3A%22discourse%22%2C%22version%22%3A%222026.9.0-latest%2029c35dd9ebd12187abfa6cf3ebb3c8075c9989f5%22%7D%7D",
            "twitter:url": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
            "favicon": "https://us1.discourse-cdn.com/grafana/optimized/2X/2/27fb03d0906653283f7bc272584543da514529de_2_32x32.png",
            "scrapeId": "01a0a962-e802-730d-becf-55260f915aae",
            "sourceURL": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
            "url": "https://community.grafana.com/t/loki-retention-policy-and-chunk-deletion-issue/159057",
            "statusCode": 200,
            "contentType": "text/html; charset=utf-8",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "2a51a82b-1a85-445f-87f8-2c882287d2f3",
            "creditsUsed": 1
          }
        },
        {
          "url": "https://www.reddit.com/r/grafana/comments/vf48rx/logs_being_deleted_from_loki/",
          "title": "Logs being deleted from Loki? : r/grafana - Reddit",
          "description": "So, I set the compactor.retention_enabled to false but it still deletes my data. I have an explanation here on what exactly I do to find the ...",
          "position": 9
        },
        {
          "url": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
          "title": "How to Implement Loki Retention Strategies - OneUptime",
          "description": "# How to Implement Loki Retention Strategies\n## Compactor-Based Retention [Link to Compactor-Based Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#compactor-based-retention)\n### Global Retention Period [Link to Global Retention Period](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#global-retention-period)\n```yaml\nYAMLCopy\n# loki-config.yaml\nlimits_config:\n  # Global retention period - logs older than this are deleted\n  retention_period: 744h  # 31 days\n```\n\n### Complete Basic Configuration [Link to Complete Basic Configuration](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#complete-basic-configuration)\n```yaml\nYAMLCopy\n# loki-config.yaml\nauth_enabled: false\n\nserver:\n  http_listen_port: 3100\n  grpc_listen_port: 9096\n\ncommon:\n  path_prefix: /loki\n  storage:\n    s3:\n      endpoint: s3.us-east-1.amazonaws.com\n      bucketnames: loki-chunks\n      region: us-east-1\n      access_key_id: ${AWS_ACCESS_KEY_ID}\n      secret_access_key: ${AWS_SECRET_ACCESS_KEY}\n      s3forcepathstyle: false\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nschema_config:\n  configs:\n    - from: 2024-01-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /loki/tsdb-index\n    cache_location: /loki/tsdb-cache\n    cache_ttl: 24h\n\ncompactor:\n  working_directory: /loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  delete_request_store: s3\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n\nlimits_config:\n  retention_period: 720h  # 30 days\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  max_streams_per_user: 10000\n  max_entries_limit_per_query: 5000\n```\n\n## Per-Tenant Retention Overrides [Link to Per-Tenant Retention Overrides](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#per-tenant-retention-overrides)\n### Stream-Based Retention [Link to Stream-Based Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#stream-based-retention)\n```yaml\nYAMLCopy\n# runtime-config.yaml\noverrides:\n  production:\n    retention_period: 720h  # Default: 30 days\n    retention_stream:\n      # Keep error logs longer\n      - selector: '{level=\"error\"}'\n        priority: 1\n        period: 2160h  # 90 days\n\n      # Keep audit logs for compliance\n      - selector: '{log_type=\"audit\"}'\n        priority: 2\n        period: 8760h  # 365 days\n\n      # Delete debug logs quickly\n      - selector: '{level=\"debug\"}'\n        priority: 3\n        period: 72h  # 3 days\n\n      # Short retention for high-volume health checks\n      - selector: '{endpoint=\"/health\"}'\n        priority: 4\n        period: 24h  # 1 day\n```\n\n## Monitoring Retention [Link to Monitoring Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#monitoring-retention)\n### Key Compactor Metrics [Link to Key Compactor Metrics](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#key-compactor-metrics)\n```yaml\nYAMLCopy\n# Prometheus recording rules for retention monitoring\ngroups:\n  - name: loki-retention\n    rules:\n      # Compactor deletion rate\n      - record: loki:compactor:deleted_lines_per_hour\n        expr: |\n          sum(rate(loki_compactor_deleted_lines[1h])) * 3600\n\n      # Pending deletion requests\n      - record: loki:compactor:pending_deletions\n        expr: |\n          sum(loki_compactor_pending_delete_requests_count)\n\n      # Compaction lag\n      - record: loki:compactor:lag_seconds\n        expr: |\n          time() - max(loki_compactor_apply_retention_last_successful_run_timestamp_seconds)\n```\n\n## Troubleshooting Retention Issues [Link to Troubleshooting Retention Issues](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#troubleshooting-retention-issues)\n### Logs Not Being Deleted [Link to Logs Not Being Deleted](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#logs-not-being-deleted)\n- `retention_enabled: false` in config",
          "position": 10,
          "markdown": "[Skip to main content](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view#main-content)\n\n![](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view)\n\n# How to Implement Loki Retention Strategies\n\nConfigure Grafana Loki retention policies with compactor-based deletion, per-tenant limits, and storage tiering for cost-effective log management.\n\n\n![Nawaz Dhandala](https://avatars.githubusercontent.com/nawazdhandala?s=64)\n\nBy @nawazdhandala\n\n\u2022Jan 30, 2026\u2022Reading time\n10 min read\n\n[Loki](https://oneuptime.com/blog/tag/loki) [Logging](https://oneuptime.com/blog/tag/logging) [Observability](https://oneuptime.com/blog/tag/observability) [Storage](https://oneuptime.com/blog/tag/storage)\n\n## On this page\n\n[Share on X](https://twitter.com/intent/tweet?text=%20How%20to%20Implement%20Loki%20Retention%20Strategies&url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on X\")[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on LinkedIn\")[Discuss on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview&t=%20How%20to%20Implement%20Loki%20Retention%20Strategies \"Discuss on Hacker News\")\n\n* * *\n\n## Introduction [Link to Introduction](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#introduction)\n\nManaging log retention in Grafana Loki requires understanding how Loki stores data and which components handle deletion. Unlike traditional databases where you simply set a TTL, Loki's architecture involves chunks, indexes, and a compactor service that work together to enforce retention policies.\n\nThis guide covers the practical implementation of retention strategies in Loki, from basic configuration to advanced per-tenant overrides. We will walk through working configurations, explain the trade-offs between different approaches, and help you build a retention strategy that balances cost with operational requirements.\n\n## Understanding Loki's Storage Model [Link to Understanding Loki's Storage Model](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#understanding-loki-s-storage-model)\n\nBefore diving into retention configuration, you need to understand how Loki stores logs.\n\n### Chunks and Indexes [Link to Chunks and Indexes](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#chunks-and-indexes)\n\nLoki stores log data in two types of objects:\n\n| Component | Purpose | Storage Backend |\n| --- | --- | --- |\n| Chunks | Compressed log data | Object storage (S3, GCS, filesystem) |\n| Index | Metadata for querying chunks | BoltDB, Cassandra, or object storage (TSDB) |\n\nChunks contain the actual log lines, compressed and grouped by stream. The index maps labels and time ranges to specific chunks, enabling efficient queries.\n\n### The TSDB Index (Recommended) [Link to The TSDB Index (Recommended)](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#the-tsdb-index-recommended)\n\nStarting with Loki 2.8, the TSDB index is the recommended schema. It stores indexes in object storage alongside chunks, simplifying operations and enabling better retention handling.\n\nHere is a basic schema configuration using TSDB:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\n\nschema_config:\n  configs:\n    - from: 2024-01-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n```\n\nThe `period: 24h` setting creates daily index tables. This matters for retention because deletion happens at the table level for older index types.\n\n## Compactor-Based Retention [Link to Compactor-Based Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#compactor-based-retention)\n\nThe compactor is Loki's primary mechanism for enforcing retention. It runs as a separate target (or within the single binary) and handles chunk deletion based on configured policies.\n\n### Enabling the Compactor [Link to Enabling the Compactor](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#enabling-the-compactor)\n\nFirst, enable the compactor and configure retention:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\ncompactor:\n  # Working directory for compaction\n  working_directory: /loki/compactor\n\n  # How often the compactor runs\n  compaction_interval: 10m\n\n  # Enable retention enforcement\n  retention_enabled: true\n\n  # Store used for delete requests\n  delete_request_store: s3\n\n  # How often to check for chunks to delete\n  retention_delete_delay: 2h\n\n  # Number of workers for deletion\n  retention_delete_worker_count: 150\n\n  # Delete request cancel period\n  delete_request_cancel_period: 24h\n```\n\nThe `retention_delete_delay` parameter adds a safety buffer. Chunks marked for deletion wait this duration before actual removal. This gives you time to cancel accidental deletions.\n\n### Global Retention Period [Link to Global Retention Period](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#global-retention-period)\n\nSet a default retention period that applies to all tenants:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\nlimits_config:\n  # Global retention period - logs older than this are deleted\n  retention_period: 744h  # 31 days\n```\n\nThe `retention_period` value uses Go duration format. Common values:\n\n| Duration | Days | Use Case |\n| --- | --- | --- |\n| 168h | 7 | Development environments |\n| 720h | 30 | Standard production |\n| 2160h | 90 | Compliance requirements |\n| 8760h | 365 | Long-term audit logs |\n\n### Complete Basic Configuration [Link to Complete Basic Configuration](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#complete-basic-configuration)\n\nHere is a complete configuration enabling compactor retention with S3 storage:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\nauth_enabled: false\n\nserver:\n  http_listen_port: 3100\n  grpc_listen_port: 9096\n\ncommon:\n  path_prefix: /loki\n  storage:\n    s3:\n      endpoint: s3.us-east-1.amazonaws.com\n      bucketnames: loki-chunks\n      region: us-east-1\n      access_key_id: ${AWS_ACCESS_KEY_ID}\n      secret_access_key: ${AWS_SECRET_ACCESS_KEY}\n      s3forcepathstyle: false\n  replication_factor: 1\n  ring:\n    kvstore:\n      store: inmemory\n\nschema_config:\n  configs:\n    - from: 2024-01-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_index_\n        period: 24h\n\nstorage_config:\n  tsdb_shipper:\n    active_index_directory: /loki/tsdb-index\n    cache_location: /loki/tsdb-cache\n    cache_ttl: 24h\n\ncompactor:\n  working_directory: /loki/compactor\n  compaction_interval: 10m\n  retention_enabled: true\n  delete_request_store: s3\n  retention_delete_delay: 2h\n  retention_delete_worker_count: 150\n\nlimits_config:\n  retention_period: 720h  # 30 days\n  ingestion_rate_mb: 10\n  ingestion_burst_size_mb: 20\n  max_streams_per_user: 10000\n  max_entries_limit_per_query: 5000\n```\n\n## Per-Tenant Retention Overrides [Link to Per-Tenant Retention Overrides](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#per-tenant-retention-overrides)\n\nIn multi-tenant deployments, different teams often have different retention requirements. Loki supports per-tenant overrides through a runtime configuration file.\n\n### Configuring Runtime Overrides [Link to Configuring Runtime Overrides](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#configuring-runtime-overrides)\n\nFirst, tell Loki where to find the overrides file:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\nruntime_config:\n  file: /loki/runtime-config.yaml\n  period: 10s  # How often to reload\n```\n\nThen create the overrides file:\n\n```yaml\nYAMLCopy\n# runtime-config.yaml\noverrides:\n  # Team with short retention needs\n  team-development:\n    retention_period: 168h  # 7 days\n    ingestion_rate_mb: 5\n    max_streams_per_user: 5000\n\n  # Team requiring longer retention for compliance\n  team-security:\n    retention_period: 8760h  # 365 days\n    ingestion_rate_mb: 20\n    max_streams_per_user: 50000\n\n  # Default tenant with standard settings\n  team-platform:\n    retention_period: 720h  # 30 days\n```\n\n### Stream-Based Retention [Link to Stream-Based Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#stream-based-retention)\n\nYou can apply different retention periods based on log stream selectors. This enables fine-grained control within a single tenant.\n\n```yaml\nYAMLCopy\n# runtime-config.yaml\noverrides:\n  production:\n    retention_period: 720h  # Default: 30 days\n    retention_stream:\n      # Keep error logs longer\n      - selector: '{level=\"error\"}'\n        priority: 1\n        period: 2160h  # 90 days\n\n      # Keep audit logs for compliance\n      - selector: '{log_type=\"audit\"}'\n        priority: 2\n        period: 8760h  # 365 days\n\n      # Delete debug logs quickly\n      - selector: '{level=\"debug\"}'\n        priority: 3\n        period: 72h  # 3 days\n\n      # Short retention for high-volume health checks\n      - selector: '{endpoint=\"/health\"}'\n        priority: 4\n        period: 24h  # 1 day\n```\n\nThe `priority` field determines which rule wins when multiple selectors match. Higher priority values take precedence.\n\n### Dynamic Override Reloading [Link to Dynamic Override Reloading](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#dynamic-override-reloading)\n\nThe compactor automatically reloads runtime configuration at the interval specified by `period`. To verify overrides are applied, check the compactor logs:\n\n```bash\nBashCopy\n# View compactor logs for retention activity\nkubectl logs -l app=loki-compactor | grep -i retention\n```\n\nYou should see entries like:\n\n```plaintext\nTextCopy\nlevel=info ts=2026-01-30T10:00:00.000Z caller=compactor.go:450 msg=\"applying retention\" tenant=team-security retention=8760h0m0s\n```\n\n## Table Manager vs Compactor Retention [Link to Table Manager vs Compactor Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#table-manager-vs-compactor-retention)\n\nLoki historically used the Table Manager for retention with BoltDB indexes. Understanding the differences helps when migrating or maintaining older deployments.\n\n### Comparison [Link to Comparison](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#comparison)\n\n| Feature | Table Manager | Compactor |\n| --- | --- | --- |\n| Index Support | Legacy chunk/index stores and BoltDB-shipper | TSDB and BoltDB-shipper |\n| Deletion Granularity | Table-level | Chunk-level |\n| Per-Tenant Overrides | Limited | Full support |\n| Stream Selectors | No | Yes |\n| Status | Deprecated | Recommended |\n\n### Table Manager Configuration (Legacy) [Link to Table Manager Configuration (Legacy)](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#table-manager-configuration-legacy)\n\nIf you are still running BoltDB indexes, here is how Table Manager retention works:\n\n```yaml\nYAMLCopy\n# loki-config.yaml (legacy configuration)\ntable_manager:\n  retention_deletes_enabled: true\n  retention_period: 720h  # 30 days\n\n  # Table creation settings\n  index_tables_provisioning:\n    inactive_read_throughput: 1\n    inactive_write_throughput: 1\n    provisioned_read_throughput: 100\n    provisioned_write_throughput: 100\n\n  chunk_tables_provisioning:\n    inactive_read_throughput: 1\n    inactive_write_throughput: 1\n    provisioned_read_throughput: 100\n    provisioned_write_throughput: 100\n```\n\n### Migration Path [Link to Migration Path](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#migration-path)\n\nTo migrate from Table Manager to Compactor retention:\n\n1. Deploy the new schema alongside the old one\n2. Enable compactor retention for new data\n3. Let Table Manager handle old data until it ages out\n4. Remove Table Manager configuration after full migration\n\n```yaml\nYAMLCopy\n# Schema configuration for migration\nschema_config:\n  configs:\n    # Old schema - Table Manager handles retention\n    - from: 2023-01-01\n      store: boltdb-shipper\n      object_store: s3\n      schema: v12\n      index:\n        prefix: loki_index_\n        period: 24h\n\n    # New schema - Compactor handles retention\n    - from: 2024-06-01\n      store: tsdb\n      object_store: s3\n      schema: v13\n      index:\n        prefix: loki_tsdb_\n        period: 24h\n```\n\n## Deletion Markers and the Deletion API [Link to Deletion Markers and the Deletion API](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#deletion-markers-and-the-deletion-api)\n\nBeyond automatic retention, Loki supports manual deletion through its API. This is useful for removing sensitive data or clearing specific log streams.\n\n### Enabling the Deletion API [Link to Enabling the Deletion API](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#enabling-the-deletion-api)\n\n```yaml\nYAMLCopy\n# loki-config.yaml\ncompactor:\n  retention_enabled: true\n  delete_request_cancel_period: 24h\n  delete_request_store: s3\n\n# runtime-config.yaml\noverrides:\n  tenant-a:\n    deletion_mode: filter-and-delete\n```\n\n### Creating Delete Requests [Link to Creating Delete Requests](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#creating-delete-requests)\n\nUse the deletion API to mark logs for removal:\n\n```bash\nBashCopy\n# Delete all logs matching a selector within a time range\ncurl -X POST \\\n  \"http://loki:3100/loki/api/v1/delete\" \\\n  -H \"Content-Type: application/x-www-form-urlencoded\" \\\n  -d \"query={app=\\\"legacy-service\\\"}\" \\\n  -d \"start=1704067200\" \\\n  -d \"end=1706745600\"\n```\n\nThe timestamps are Unix timestamps in seconds or RFC3339 timestamps. Convert from dates:\n\n```bash\nBashCopy\n# Convert dates to Unix timestamps in seconds\nSTART=$(date -d \"2024-01-01\" +%s)\nEND=$(date -d \"2024-02-01\" +%s)\n\ncurl -X POST \\\n  \"http://loki:3100/loki/api/v1/delete\" \\\n  -d \"query={app=\\\"legacy-service\\\"}\" \\\n  -d \"start=${START}\" \\\n  -d \"end=${END}\"\n```\n\n### Listing and Canceling Delete Requests [Link to Listing and Canceling Delete Requests](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#listing-and-canceling-delete-requests)\n\nView pending deletions:\n\n```bash\nBashCopy\n# List all delete requests\ncurl \"http://loki:3100/loki/api/v1/delete\"\n```\n\nResponse:\n\n```json\nJSONCopy\n[\\\n  {\\\n    \"request_id\": \"abc123\",\\\n    \"start_time\": 1704067200,\\\n    \"end_time\": 1706745600,\\\n    \"query\": \"{app=\\\"legacy-service\\\"}\",\\\n    \"status\": \"received\",\\\n    \"created_at\": 1706800000\\\n  }\\\n]\n```\n\nCancel a pending deletion (within the cancel period):\n\n```bash\nBashCopy\ncurl -X DELETE \\\n  \"http://loki:3100/loki/api/v1/delete?request_id=abc123\"\n```\n\n### Delete Request States [Link to Delete Request States](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#delete-request-states)\n\n| State | Description |\n| --- | --- |\n| received | Request received, waiting for cancel period |\n| building | Cancel period passed, building deletion plan |\n| deleting | Actively deleting chunks |\n| processed | Deletion complete |\n\n## Storage Considerations [Link to Storage Considerations](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#storage-considerations)\n\nRetention configuration directly impacts storage costs and performance. Here are key considerations for production deployments.\n\n### Object Storage Lifecycle Policies [Link to Object Storage Lifecycle Policies](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#object-storage-lifecycle-policies)\n\nCombine Loki retention with cloud provider lifecycle policies for defense in depth:\n\n```json\nJSONCopy\n{\n  \"Rules\": [\\\n    {\\\n      \"ID\": \"loki-chunks-cleanup\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"loki/chunks/\"\\\n      },\\\n      \"Expiration\": {\\\n        \"Days\": 45\\\n      }\\\n    },\\\n    {\\\n      \"ID\": \"loki-index-cleanup\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"loki/index/\"\\\n      },\\\n      \"Expiration\": {\\\n        \"Days\": 45\\\n      }\\\n    }\\\n  ]\n}\n```\n\nSet the lifecycle policy expiration slightly longer than your Loki retention to catch any orphaned objects.\n\n### Storage Tiering for Cost Optimization [Link to Storage Tiering for Cost Optimization](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#storage-tiering-for-cost-optimization)\n\nMove older logs to cheaper storage tiers before deletion:\n\n```json\nJSONCopy\n{\n  \"Rules\": [\\\n    {\\\n      \"ID\": \"loki-tiering\",\\\n      \"Status\": \"Enabled\",\\\n      \"Filter\": {\\\n        \"Prefix\": \"loki/\"\\\n      },\\\n      \"Transitions\": [\\\n        {\\\n          \"Days\": 7,\\\n          \"StorageClass\": \"STANDARD_IA\"\\\n        },\\\n        {\\\n          \"Days\": 30,\\\n          \"StorageClass\": \"GLACIER_IR\"\\\n        }\\\n      ],\\\n      \"Expiration\": {\\\n        \"Days\": 90\\\n      }\\\n    }\\\n  ]\n}\n```\n\n### Chunk Size and Compression [Link to Chunk Size and Compression](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#chunk-size-and-compression)\n\nOptimize chunk configuration to reduce storage:\n\n```yaml\nYAMLCopy\n# loki-config.yaml\ningester:\n  chunk_encoding: snappy  # Options: gzip, lz4, snappy, zstd\n  chunk_target_size: 1572864  # 1.5MB target\n  chunk_idle_period: 30m\n  chunk_block_size: 262144  # 256KB\n\n  # Flush chunks before they get too old\n  max_chunk_age: 2h\n\n  # Number of chunks to keep in memory\n  chunk_retain_period: 30s\n```\n\nCompression comparison:\n\n| Algorithm | Compression Ratio | CPU Usage | Best For |\n| --- | --- | --- | --- |\n| snappy | Good | Low | General use |\n| lz4 | Good | Low | High throughput |\n| gzip | Better | Medium | Storage constrained |\n| zstd | Best | Medium-High | Cold storage |\n\n## Monitoring Retention [Link to Monitoring Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#monitoring-retention)\n\nTrack retention effectiveness with these metrics.\n\n### Key Compactor Metrics [Link to Key Compactor Metrics](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#key-compactor-metrics)\n\n```yaml\nYAMLCopy\n# Prometheus recording rules for retention monitoring\ngroups:\n  - name: loki-retention\n    rules:\n      # Compactor deletion rate\n      - record: loki:compactor:deleted_lines_per_hour\n        expr: |\n          sum(rate(loki_compactor_deleted_lines[1h])) * 3600\n\n      # Pending deletion requests\n      - record: loki:compactor:pending_deletions\n        expr: |\n          sum(loki_compactor_pending_delete_requests_count)\n\n      # Compaction lag\n      - record: loki:compactor:lag_seconds\n        expr: |\n          time() - max(loki_compactor_apply_retention_last_successful_run_timestamp_seconds)\n```\n\n### Alerting Rules [Link to Alerting Rules](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#alerting-rules)\n\n```yaml\nYAMLCopy\n# Prometheus alerting rules\ngroups:\n  - name: loki-retention-alerts\n    rules:\n      # Alert if compactor is not running\n      - alert: LokiCompactorNotRunning\n        expr: |\n          time() - max(loki_compactor_apply_retention_last_successful_run_timestamp_seconds) > 3600\n        for: 15m\n        labels:\n          severity: warning\n        annotations:\n          summary: \"Loki compactor has not run in over an hour\"\n          description: \"Retention policies are not being enforced\"\n\n      # Alert on high deletion backlog\n      - alert: LokiDeletionBacklog\n        expr: |\n          loki_compactor_pending_delete_requests_count > 100\n        for: 1h\n        labels:\n          severity: warning\n        annotations:\n          summary: \"High number of pending deletion requests\"\n\n      # Alert if old delete requests are not being processed\n      - alert: LokiOldestDeleteRequestStalled\n        expr: |\n          loki_compactor_oldest_pending_delete_request_age_seconds > 86400\n        for: 6h\n        labels:\n          severity: info\n        annotations:\n          summary: \"Old Loki delete requests are still pending\"\n```\n\n### Grafana Dashboard Queries [Link to Grafana Dashboard Queries](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#grafana-dashboard-queries)\n\nCreate a retention monitoring dashboard:\n\n```sql\nSQLCopy\n-- Deleted lines over time\nsum(rate(loki_compactor_deleted_lines[$__rate_interval])) by (user)\n\n-- Pending delete requests\nsum(loki_compactor_pending_delete_requests_count)\n\n-- Delete requests processed over time\nsum(rate(loki_compactor_delete_requests_processed_total[$__rate_interval])) by (user)\n\n-- Oldest pending delete request age\nmax(loki_compactor_oldest_pending_delete_request_age_seconds)\n```\n\n## Production Deployment Patterns [Link to Production Deployment Patterns](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#production-deployment-patterns)\n\n### Single Binary with Retention [Link to Single Binary with Retention](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#single-binary-with-retention)\n\nFor smaller deployments, run everything in one process:\n\n```yaml\nYAMLCopy\n# docker-compose.yml\nservices:\n  loki:\n    image: grafana/loki:3.7.1\n    ports:\n      - \"3100:3100\"\n    volumes:\n      - ./loki-config.yaml:/etc/loki/config.yaml\n      - ./runtime-config.yaml:/loki/runtime-config.yaml\n      - loki-data:/loki\n    command: -config.file=/etc/loki/config.yaml -target=all\n\nvolumes:\n  loki-data:\n```\n\n### Dedicated Compactor in Microservices Mode [Link to Dedicated Compactor in Microservices Mode](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#dedicated-compactor-in-microservices-mode)\n\nFor larger deployments, run the compactor as a dedicated service:\n\n```yaml\nYAMLCopy\n# kubernetes/compactor-deployment.yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: loki-compactor\nspec:\n  replicas: 1  # Only one compactor instance\n  selector:\n    matchLabels:\n      app: loki-compactor\n  template:\n    metadata:\n      labels:\n        app: loki-compactor\n    spec:\n      containers:\n        - name: compactor\n          image: grafana/loki:3.7.1\n          args:\n            - -config.file=/etc/loki/config.yaml\n            - -target=compactor\n          ports:\n            - containerPort: 3100\n              name: http\n          volumeMounts:\n            - name: config\n              mountPath: /etc/loki\n            - name: data\n              mountPath: /loki\n          resources:\n            requests:\n              cpu: 500m\n              memory: 1Gi\n            limits:\n              cpu: 2000m\n              memory: 4Gi\n      volumes:\n        - name: config\n          configMap:\n            name: loki-config\n        - name: data\n          persistentVolumeClaim:\n            claimName: loki-compactor-data\n```\n\nThe compactor must run as a singleton. Running multiple instances causes data corruption.\n\n### Helm Chart Configuration [Link to Helm Chart Configuration](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#helm-chart-configuration)\n\nUsing the official Loki Helm chart:\n\n```yaml\nYAMLCopy\n# values.yaml\nloki:\n  auth_enabled: false\n\n  commonConfig:\n    replication_factor: 1\n\n  storage:\n    type: s3\n    bucketNames:\n      chunks: loki-chunks\n      ruler: loki-ruler\n      admin: loki-admin\n    s3:\n      endpoint: s3.us-east-1.amazonaws.com\n      region: us-east-1\n\n  storage_config:\n    aws:\n      region: us-east-1\n      bucketnames: loki-chunks\n      s3forcepathstyle: false\n\n  schemaConfig:\n    configs:\n      - from: 2024-01-01\n        store: tsdb\n        object_store: s3\n        schema: v13\n        index:\n          prefix: loki_index_\n          period: 24h\n\n  limits_config:\n    retention_period: 720h\n\n  compactor:\n    retention_enabled: true\n    delete_request_store: s3\n    retention_delete_delay: 2h\n    retention_delete_worker_count: 150\n\n  # Runtime configuration for per-tenant overrides\n  runtimeConfig:\n    overrides:\n      team-a:\n        retention_period: 168h\n      team-b:\n        retention_period: 2160h\n\ncompactor:\n  replicas: 1\n  persistence:\n    enabled: true\n    claims:\n      - name: data\n        size: 10Gi\n```\n\n## Troubleshooting Retention Issues [Link to Troubleshooting Retention Issues](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#troubleshooting-retention-issues)\n\n### Logs Not Being Deleted [Link to Logs Not Being Deleted](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#logs-not-being-deleted)\n\nCheck the compactor is running and retention is enabled:\n\n```bash\nBashCopy\n# Check compactor status\ncurl http://loki:3100/compactor/ring\n\n# Check if retention is enabled in config\ncurl http://loki:3100/config | grep -A 10 \"compactor\"\n```\n\nCommon causes:\n\n- `retention_enabled: false` in config\n- Compactor not reaching the chunks (network or permission issues)\n- Delete delay has not passed yet\n\n### Debugging Retention Boundaries [Link to Debugging Retention Boundaries](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#debugging-retention-boundaries)\n\nVerify what the compactor sees as retention boundaries:\n\n```bash\nBashCopy\n# Check compactor logs for retention decisions\nkubectl logs deployment/loki-compactor | grep \"retention boundary\"\n```\n\n### Storage Not Decreasing [Link to Storage Not Decreasing](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#storage-not-decreasing)\n\nIf storage does not decrease after retention runs:\n\n1. Check if lifecycle policies are conflicting\n2. Verify the compactor has write access to delete objects\n3. Look for orphaned chunks from failed compactions\n\n```bash\nBashCopy\n# List objects that should have been deleted\naws s3 ls s3://loki-chunks/chunks/ --recursive | \\\n  awk '$1 < \"2024-01-01\" {print $4}'\n```\n\n### Per-Tenant Overrides Not Applied [Link to Per-Tenant Overrides Not Applied](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#per-tenant-overrides-not-applied)\n\nVerify runtime config is loaded:\n\n```bash\nBashCopy\n# Check runtime config hash\ncurl http://loki:3100/runtime_config?mode=diff\n```\n\nEnsure the tenant ID matches exactly (case-sensitive).\n\n## Best Practices Summary [Link to Best Practices Summary](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#best-practices-summary)\n\n1. **Start with compactor retention** \\- Table Manager is deprecated and has limited functionality.\n\n2. **Set conservative defaults** \\- Start with longer retention and reduce based on observed usage patterns.\n\n3. **Use stream selectors wisely** \\- Apply longer retention only to high-value logs like errors and audit trails.\n\n4. **Monitor compaction lag** \\- A backlog indicates the compactor cannot keep up with ingestion.\n\n5. **Combine with lifecycle policies** \\- Use cloud provider policies as a safety net, not the primary mechanism.\n\n6. **Test deletion in staging** \\- Verify retention policies work correctly before applying to production.\n\n7. **Document retention policies** \\- Teams need to know how long their logs persist for debugging and compliance.\n\n8. **Plan for growth** \\- Ingestion typically grows faster than deletion, so build in headroom.\n\n\n## Conclusion [Link to Conclusion](https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view\\#conclusion)\n\nImplementing effective retention in Loki requires configuring the compactor correctly and understanding how chunks and indexes interact. Start with the compactor-based approach using TSDB indexes for new deployments. Use per-tenant overrides to give teams flexibility while maintaining cost control. Monitor retention effectiveness with dedicated dashboards and alerts to catch issues before storage costs spiral.\n\nThe configurations in this guide provide a solid foundation. Adjust retention periods based on your compliance requirements, debugging needs, and budget constraints. Remember that retention is a balance - too short and you lose valuable debugging context, too long and storage costs become unsustainable.\n\nShare this article\n\n[Share on X](https://twitter.com/intent/tweet?text=%20How%20to%20Implement%20Loki%20Retention%20Strategies&url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on X\")[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview \"Share on LinkedIn\")[Discuss on Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Foneuptime.com%2Fblog%2Fpost%2F2026-01-30-loki-retention-strategies%2Fview&t=%20How%20to%20Implement%20Loki%20Retention%20Strategies \"Discuss on Hacker News\")\n\n![Nawaz Dhandala](https://avatars.githubusercontent.com/nawazdhandala)\n\n### Nawaz Dhandala\n\nAuthor\n\n@nawazdhandala \u2022 Jan 30, 2026 \u2022 10 min read\n\nNawaz is building OneUptime with a passion for engineering reliable systems and improving observability.\n\n[GitHub](https://github.com/nawazdhandala)\n\nTechnically validated\u00b7 Jun 11, 2026\nView report\n\n\n### Help improve this post\n\nEvery OneUptime blog post is open source. Found a typo, an inaccuracy, or have a clearer way to explain something? Anyone can contribute \u2014 your edits make this post better for everyone who reads it next.\n\n[Edit this post on GitHub](https://github.com/oneuptime/blog/tree/master/posts/2026-01-30-loki-retention-strategies) [Contributing guidelines](https://github.com/oneuptime/blog)\n\n[Open source](https://github.com/oneuptime/oneuptime)\n\n## OneUptime is the Open-Source   Observability Platform\n\nYour complete reliability stack unified: infrastructure monitoring, incident management, status pages, and APM. Open-source and self-hostable.\n\n\n[Get started for free](https://oneuptime.com/accounts/register) [Request a demo](https://oneuptime.com/enterprise/demo)\n\n[Status Page\\\\\n\\\\\nReal-time status updates](https://oneuptime.com/product/status-page) [Incidents\\\\\n\\\\\nDetect and resolve fast](https://oneuptime.com/product/incident-management) [Monitoring\\\\\n\\\\\nMonitor any resource](https://oneuptime.com/product/monitoring) [On-Call\\\\\n\\\\\nSmart alert routing](https://oneuptime.com/product/on-call) [Maintenance\\\\\n\\\\\nPlan & communicate downtime](https://oneuptime.com/product/scheduled-maintenance) [Logs\\\\\n\\\\\nFastest log ingest and search](https://oneuptime.com/product/logs-management) [Metrics\\\\\n\\\\\nPerformance insights](https://oneuptime.com/product/metrics) [Traces\\\\\n\\\\\nEnd-to-end distributed tracing](https://oneuptime.com/product/traces) [Exceptions\\\\\n\\\\\nCatch and fix bugs early](https://oneuptime.com/product/exceptions) [Workflows\\\\\n\\\\\nAutomate any process](https://oneuptime.com/product/workflows) [Dashboards\\\\\n\\\\\nVisualize all your data](https://oneuptime.com/product/dashboards) [Kubernetes\\\\\n\\\\\nMonitor K8s clusters](https://oneuptime.com/product/kubernetes) [Profiles\\\\\n\\\\\nCPU & memory profiling](https://oneuptime.com/product/profiles)\n\n[AI\\\\\n\\\\\nDetect, diagnose, and resolve incidents with AI-powered root cause analysis and code fixes.](https://oneuptime.com/product/ai-agent)\n\n## Validation report\n\nTechnically reviewed for accuracy \u2022Jun 11, 2026\n\nLoading validation report\u2026\n\n\nAutomated technical review\nClose",
          "metadata": {
            "twitter:data1": "Nawaz Dhandala",
            "apple-mobile-web-app-status-bar-style": "default",
            "ogDescription": " Configure Grafana Loki retention policies with compactor-based deletion, per-tenant limits, and storage tiering for cost-effective log management.",
            "viewport": "width=device-width, initial-scale=1, shrink-to-fit=no, viewport-fit=cover",
            "twitter:card": "summary_large_image",
            "publishedTime": "2026-01-30T00:00:00.000Z",
            "apple-mobile-web-app-capable": "yes",
            "title": "\n         How to Implement Loki Retention Strategies\n    ",
            "mobile-web-app-capable": "yes",
            "msapplication-TileImage": "/img/favicons/mstile-144x144.png",
            "twitter:description": " Configure Grafana Loki retention policies with compactor-based deletion, per-tenant limits, and storage tiering for cost-effective log management.",
            "twitter:label1": "Written by",
            "msapplication-TileColor": "#000000",
            "og:title": " How to Implement Loki Retention Strategies",
            "article:published_time": "2026-01-30T00:00:00.000Z",
            "article:publisher": "https://www.facebook.com/OneUptime",
            "og:image:height": "720",
            "article:modified_time": "2026-01-30T00:00:00.000Z",
            "modifiedTime": "2026-01-30T00:00:00.000Z",
            "ogUrl": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
            "twitter:title": " How to Implement Loki Retention Strategies",
            "og:description": " Configure Grafana Loki retention policies with compactor-based deletion, per-tenant limits, and storage tiering for cost-effective log management.",
            "twitter:image": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/social-media.png",
            "ogImage": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/social-media.png",
            "language": "en",
            "og:type": "article",
            "og:image:width": "1280",
            "apple-mobile-web-app-title": "OneUptime",
            "og:url": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
            "twitter:site": "@OneUptimeHQ",
            "og:site_name": "OneUptime | One Complete Observability platform.",
            "ogTitle": " How to Implement Loki Retention Strategies",
            "ogSiteName": "OneUptime | One Complete Observability platform.",
            "description": " Configure Grafana Loki retention policies with compactor-based deletion, per-tenant limits, and storage tiering for cost-effective log management.",
            "og:image": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/social-media.png",
            "theme-color": [
              "#000000",
              "#000000",
              "#1E293B"
            ],
            "twitter:url": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
            "application-name": "OneUptime",
            "favicon": "https://oneuptime.com/img/favicons/favicon-32x32.png?v=up-v1",
            "scrapeId": "01a0a962-e802-730d-becf-59a7c202263b",
            "sourceURL": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
            "url": "https://oneuptime.com/blog/post/2026-01-30-loki-retention-strategies/view",
            "statusCode": 200,
            "contentType": "text/html; charset=utf-8",
            "timezone": "America/New_York",
            "proxyUsed": "basic",
            "cacheState": "miss",
            "indexId": "a029a84f-1c05-4fbc-94d5-6d5475410502",
            "creditsUsed": 1
          }
        }
      ]
    },
    "creditsUsed": 11,
    "id": "01a0a962-e645-758d-aff6-e1915767d746"
  }
}