You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Loki配置:如何用Minio做热存储、S3做冷存储?

Loki 分层存储配置:Minio 存近期数据,S3 存历史数据

可以通过 Loki 的多存储后端 + 时间分段 schema 配置实现你的需求——让 0-48 小时的新数据存在 Minio,超过 48 小时的历史数据归档到 S3。以下是具体配置方案:

核心配置修改步骤

1. 配置双存储后端

在 storage_config 中同时定义 Minio 和 S3 两个存储实例,分别命名以便后续绑定:

storage_config:
  aws:
    - name: minio
      s3: s3://loki:supersecret@minio:9000/loki-data
      insecure: true
      s3forcepathstyle: true
    - name: s3
      s3: s3://us-west-2
      bucketnames: abc-loki-data
      endpoint: https://s3.us-west-2.amazonaws.com

2. 按时间分段配置 Schema

修改 schema_config,拆分出两个时间规则段,分别绑定 Minio 和 S3:

schema_config:
  configs:
    - from: "now-48h"
      store: tsdb
      object_store: minio
      schema: v13
      index:
        prefix: index_minio_
        period: 24h
    - from: 2023-01-01
      store: tsdb
      object_store: s3
      schema: v13
      index:
        prefix: index_s3_
        period: 24h

说明:now-48h 表示从当前时间往前推 48 小时的节点,之后产生的新数据都会写入 Minio;2023-01-01 至今(除最近48小时)的历史数据会读取/写入 S3。如果是已有历史数据的环境,需确保时间边界不会导致数据错乱,建议先在测试环境验证。

3. 调整全局与组件配置

  • 移除 common 块中的 storage 子配置,因为现在使用多存储后端,不需要全局默认存储
  • 保留 ruler 和 compactor 的现有 S3 配置(如果规则数据和压缩操作需要统一用 S3)

完整配置示例

---
server:
  http_listen_address: 0.0.0.0
  http_listen_port: 3100

auth_enabled: false

memberlist:
  join_members: ["read", "write", "backend"]
  dead_node_reclaim_time: 30s
  gossip_to_dead_nodes_time: 15s
  left_ingesters_timeout: 30s
  bind_addr: ['0.0.0.0']
  bind_port: 7946
  gossip_interval: 2s

schema_config:
  configs:
    - from: "now-48h"
      store: tsdb
      object_store: minio
      schema: v13
      index:
        prefix: index_minio_
        period: 24h
    - from: 2023-01-01
      store: tsdb
      object_store: s3
      schema: v13
      index:
        prefix: index_s3_
        period: 24h

common:
  path_prefix: /loki
  replication_factor: 1
  compactor_address: http://backend:3100
  ring:
    kvstore:
      store: memberlist

ruler:
  storage:
    s3:
      bucketnames: abc-loki-data
      endpoint: https://s3.us-west-2.amazonaws.com

compactor:
  working_directory: /tmp/compactor
  compaction_interval: 10m
  retention_enabled: true
  retention_delete_delay: 2h
  retention_delete_worker_count: 150
  delete_request_store: s3

storage_config:
  aws:
    - name: minio
      s3: s3://loki:supersecret@minio:9000/loki-data
      insecure: true
      s3forcepathstyle: true
    - name: s3
      s3: s3://us-west-2
      bucketnames: abc-loki-data
      endpoint: https://s3.us-west-2.amazonaws.com

注意事项

  • 提前创建 Minio 的 loki-data 桶和 S3 的 abc-loki-data 桶
  • 验证 Loki 实例对两个存储的读写权限正常
  • 若已有历史数据,需确保时间分段规则不会影响现有数据的读取

内容的提问来源于stack exchange,提问作者Jimmy lao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 12:07:24