V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Ritter
V2EX  ›  日志处理

Loki 的 filename 标签为什么过了 24 小时就丢失了

  •  
  •   Ritter · 2023-03-03 15:30:36 +08:00 · 300 次点击
    这是一个创建于 421 天前的主题,其中的信息可能已经有所发展或是发生改变。

    应用内日志做了按天的轮转,存储时间是 7 天,通过边车容器 promtail 挂载共享卷 push 到 Loki
    Loki 的话也挂载了持久卷,并且设置了 15 天存储和最大回看周期,刚部署完第一天 push 了所有的日志包括轮转日志,在 grafana 也能看到 filename 标签包含了所有文件,但是第二天查看的时候 filename 标签只有轮转日志了,举个简单的例子就是:
    day1:
    filename => app.log app.log.2023-03-01 app.log.2023-03-02
    day2:
    filename => app.log
    app.log 为轮转文件,日志轮转模式为 rename-create 模式,看 Loki 文档也是推荐使用这种模式
    以下为 Loki 的配置文件

    auth_enabled: false
    server:
      http_listen_port: 3100
    common:
      path_prefix: /data/loki
    chunk_store_config:
      max_look_back_period: 360h
    compactor:
      shared_store: filesystem
      working_directory: /data/loki/boltdb-shipper-compactor
    ingester:
      chunk_block_size: 262144
      chunk_idle_period: 3m
      chunk_retain_period: 1m
      lifecycler:
        ring:
          kvstore:
            store: inmemory
          replication_factor: 1
      max_transfer_retries: 0
    limits_config:
      enforce_metric_name: false
      reject_old_samples: true
      reject_old_samples_max_age: 168h
    schema_config:
      configs:
      - from: "2023-01-01"
        index:
          period: 24h
          prefix: index_
        chunks:
          period: 24h
          prefix: chunk_
        object_store: filesystem
        schema: v11
        store: boltdb-shipper
    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: 360h
    

    我估计是 schema_config 内 index 的 period 设置出的问题,我理解这个设置的意思是在 24h 后重建索引,但是不明白 Loki 重建索引的规则是什么,为什么只有 filename 的 label 丢失了,有大佬解答一下吗

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   877 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:30 · PVG 05:30 · LAX 14:30 · JFK 17:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.