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

2023-03-03 15:30:36 +08:00
 Ritter

应用内日志做了按天的轮转,存储时间是 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 丢失了,有大佬解答一下吗

313 次点击
所在节点    日志处理
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/920852

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX