Grafana Loki Log retention period

This is my loki configuration. I want to do two things.

  1. Set the retention period for logs to 90 days
  2. Store cache locally and not on object storage.

Please help me out with the configuration changes I need to make.

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

storage_config:
  boltdb_shipper:
    active_index_directory: /var/lib/loki/boltdb-shipper-active
    cache_location: /var/lib/loki/boltdb-shipper-cache
    cache_ttl: 24h         # Can be increased for faster performance over longer query periods, uses more disk space
    shared_store: gcs
  gcs:
      bucket_name: bucket-name
common:
  path_prefix: /opt/loki
  storage:
    gcs:
     bucket_name: arista-loki
  replication_factor: 3
  ring:
    kvstore:
      store: memberlist
query_range:
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 100

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: gcs
      schema: v11
      index:
        prefix: index_
        period: 24h

memberlist:
  join_members:
   - loki01:7946
   - loki02:7946
   - loki03:7946

You need two things for retention. First the compactor:

compactor:
  <OTHER_CONFIG>
  retention_enabled: true
  shared_store: s3

Then set retention period in limits configuration:

limits_config:
  <OTHER_CONFIG>
  retention_period: <__>

Also see Retention | Grafana Loki documentation.

As for index cache, pretty sure it’s already local, though I could be wrong.

There’s no data in the cache directory mentioned in the configuration.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.