使用Loki+S3配置存储保留的最佳方式



我使用的是Loki v2.4.2,并已将S3配置为索引和区块的存储后端。

我想确保所有超过90天的日志都被删除,而没有损坏的风险。有关保留的文档令人困惑,步骤也不清楚。我应该只在根前缀(即/(上设置对象存储的TTL吗。或者我应该配置这样的东西吗?我不想开动压实机。

table_manager:
retention_deletes_enabled: true
retention_period: 2160h

这是我的洛基配置。请建议在此配置中应进行哪些更改以及相应的S3 TTL。我不想开动压实机。

config:
# existingSecret:
auth_enabled: false
ingester:
chunk_idle_period: 3m
chunk_block_size: 262144
chunk_retain_period: 1m
max_transfer_retries: 0
wal:
dir: /data/loki/wal
lifecycler:
ring:
kvstore:
store: inmemory
replication_factor: 1
## Different ring configs can be used. E.g. Consul
# ring:
#   store: consul
#   replication_factor: 1
#   consul:
#     host: "consul:8500"
#     prefix: ""
#     http_client_timeout: "20s"
#     consistent_reads: true
limits_config:
max_query_series: 5000
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
schema_config:
configs:
- from: 2021-09-27
store: boltdb-shipper
object_store: s3
schema: v11
index:
prefix: index_
period: 24h
server:
http_listen_port: 3100
storage_config:
aws:
s3: s3://ap-southeast-1/loki-s3-bucket
boltdb_shipper:
active_index_directory: /data/loki/boltdb-shipper-active
cache_location: /data/loki/boltdb-shipper-cache
cache_ttl: 24h         # Can be increased for faster performance over longer query periods, uses more disk space
shared_store: s3
filesystem:
directory: /data/loki/chunks
chunk_store_config:
max_look_back_period: 0s
table_manager:
retention_deletes_enabled: false
retention_period: 0s
compactor:
working_directory: /data/loki/boltdb-shipper-compactor
shared_store: filesystem

删除旧日志和索引数据似乎是S3的责任,而不是Loki的责任。您需要向存储桶中添加一个或多个生命周期规则来处理此问题。

https://grafana.com/docs/loki/latest/operations/storage/retention/#table-经理

"当使用S3或GCS时,存储区块的存储桶需要正确设置到期策略。有关更多详细信息,请查看S3的文件或GCS的文件">

国际海事组织的洛基文件在这个话题上非常薄弱,我希望他们能更详细地讨论这个问题。