如何仅保留Loki日志7天

huangapple go评论57阅读模式
英文:

How do I keep loki logs for only 7 days

问题

I want to keep the logs of loki within 7 days. As I hope to pass the test and know how to modify, I set the log within 2 minutes, and the logs before 2 minutes will be cleared and deleted, but my requirement has not been realized. Who can help me check

This is my loki configuration file

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: loki-config
  namespace: logging
  labels:
    helm.sh/chart: promtail-3.11.0
    app.kubernetes.io/name: promtail
    app.kubernetes.io/instance: loki
    app.kubernetes.io/version: "2.4.2"
    app.kubernetes.io/managed-by: Helm
data:
  loki.yaml: |
    auth_enabled: false
    chunk_store_config:
      max_look_back_period: 0s
    compactor:
      shared_store: filesystem
      working_directory: /data/loki/boltdb-shipper-compactor
    ingester:
      chunk_block_size: 262144
      chunk_idle_period: 3m
      chunk_retain_period: 2m
      lifecycler:
        ring:
          kvstore:
            store: inmemory
          replication_factor: 1
      max_transfer_retries: 0
      wal:
        dir: /data/loki/wal
    limits_config:
      enforce_metric_name: false
      reject_old_samples: true
      reject_old_samples_max_age: 168h
    schema_config:
      configs:
      - from: "2020-10-24"
        index:
          period: 24h
          prefix: index_
        object_store: filesystem
        schema: v11
        store: boltdb-shipper
    server:
      http_listen_port: 3100
    storage_config:
      boltdb_shipper:
        active_index_directory: /data/loki/boltdb-shipper-active
        cache_location: /data/loki/boltdb-shipper-cache
        cache_ttl: 24h
        shared_store: filesystem
      filesystem:
        directory: /data/loki/chunks
    table_manager:
      retention_deletes_enabled: true
      retention_period: 2m    

I looked at grafana, but the log is still not deleted, there are still logs from 2 minutes ago, how should I adjust and keep loki's log, I want to delete the old log

英文:

I want to keep the logs of loki within 7 days. As I hope to pass the test and know how to modify, I set the log within 2 minutes, and the logs before 2 minutes will be cleared and deleted, but my requirement has not been realized. Who can help me check

This is my loki configuration file

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: loki-config
  namespace: logging
  labels:
    helm.sh/chart: promtail-3.11.0
    app.kubernetes.io/name: promtail
    app.kubernetes.io/instance: loki
    app.kubernetes.io/version: "2.4.2"
    app.kubernetes.io/managed-by: Helm
data:
  loki.yaml: |
    auth_enabled: false
    chunk_store_config:
      max_look_back_period: 0s
    compactor:
      shared_store: filesystem
      working_directory: /data/loki/boltdb-shipper-compactor
    ingester:
      chunk_block_size: 262144
      chunk_idle_period: 3m
      chunk_retain_period: 2m
      lifecycler:
        ring:
          kvstore:
            store: inmemory
          replication_factor: 1
      max_transfer_retries: 0
      wal:
        dir: /data/loki/wal
    limits_config:
      enforce_metric_name: false
      reject_old_samples: true
      reject_old_samples_max_age: 168h
    schema_config:
      configs:
      - from: "2020-10-24"
        index:
          period: 24h
          prefix: index_
        object_store: filesystem
        schema: v11
        store: boltdb-shipper
    server:
      http_listen_port: 3100
    storage_config:
      boltdb_shipper:
        active_index_directory: /data/loki/boltdb-shipper-active
        cache_location: /data/loki/boltdb-shipper-cache
        cache_ttl: 24h
        shared_store: filesystem
      filesystem:
        directory: /data/loki/chunks
    table_manager:
      retention_deletes_enabled: true
      retention_period: 2m

I looked at grafana, but the log is still not deleted, there are still logs from 2 minutes ago, how should I adjust and keep loki's log, I want to delete the old log

如何仅保留Loki日志7天

答案1

得分: 1

配置保留期需要以下设置:

...
# 配置压实组件,用于为性能压实索引分片
压实器:
  # 激活自定义保留期(默认=false)
  保留期启用:true
...
# 配置每租户或全局限制
限制配置:
  # 保留期适用于存储,如果在压实器端启用了保留期(默认=744小时)
  保留期:2分钟
...
英文:

To set the retention period you need the following configuration:

...
# Configures the compactor component which compacts index shards for performance
compactor:
  # Activate custom retention (default=false)
  retention_enabled: true
...
# Configures limits per-tenant or globally
limits_config:
  # Retention to apply for the store, if the retention is enabled on the compactor side (default=744h)
  retention_period: 2m
...

huangapple
  • 本文由 发表于 2023年4月19日 16:05:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052085.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定