Loki配置存储有效期

文章目录

背景

公司的向上服务是使用的Grafana+Promtail+Loki,Grafana负责数据呈现,Promtail负责日志的收集,Loki负责日志存储。相对于ELK的模式,要小不少,部署也非常容易,每日日志产生量100G以下的项目,都可以使用单例的Loki进行支持。随着项目的发展,日志存储磁盘越来越大,再次记录下配置存储有效期过程,以备有需要的老伙计参考

配置

Loki的配置部分相对还是蛮简单的,我所使用的Loki版本是 2.9.0。最新版本已经到3.1.0了,需要注意的是如果是搭建,最好是确保grafana+promtail+loki的版本兼容。过期部分的官方文档可以看这里 storage/retention,这里直接贴出对应的配置内容

auth_enabled: false

server:
  http_listen_port: 3100
  grpc_listen_port: 9096

common:
  instance_addr: 127.0.0.1
  path_prefix: /tmp/loki
  storage:
    filesystem:
      chunks_directory: /tmp/loki/chunks
      rules_directory: /tmp/loki/rules
  replication_factor: 1
  ring:
    kvstore:
      store: inmemory
compactor:
  working_directory: /tmp/loki/retention
  compaction_interval: 10m
  retention_enabled: true
  retention_delete_delay: 2h
  retention_delete_worker_count: 150
  delete_request_store: filesystem

limits_config:
  retention_period: 2160h
  max_query_lookback: 2160h
query_range:
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 2048

schema_config:
  configs:
    - from: 2020-10-24
      store: boltdb-shipper
      object_store: filesystem
      schema: v11
      index:
        prefix: index_
        period: 24h

#storage_config:
#  boltdb_shipper:
#    active_index_directory: /tmp/loki/boltdb-shipper-active
#    cache_location: /tmp/loki/boltdb-shipper-cache

ruler:
  alertmanager_url: http://localhost:9093

我所遇到的坑是这里的compactor.delete_request_store,我理解的既然是store,是不是就应该填写的是schema_config中的store,结果不管是填config 还是填写 boltdb-shipper都不对,都会导致启动错误
error running loki" err="failed to init delete store. Object client not found for boltdb-shipper
如果将配置注解掉,正确的做法是这里要填写filesystem,即schema_config 中指定的object_store
另外需要注意的如果需要开启retention_enabledindex.period必须要24h

  • 6
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Loki是一个开源的分布式日志聚合系统,它可以将多个不同来源的日志数据聚合到一个统一的地方,并提供了强大的搜索和查询功能。Loki配置文件包含了Loki的所有配置信息,下面是对Loki配置文件的详细解释: 1. server段 server段包含了Loki服务器的配置信息,包括监听地址和端口、存储位置、日志级别等。 示例: ``` server: http_listen_port: 3100 grpc_listen_port: 9095 log_level: info config: auth_enabled: false server: http_listen_port: 3100 grpc_listen_port: 9095 ``` 2. schema_config段 schema_config段用于配置Loki日志格式,包括日志标签和日志字段。可以使用正则表达式来匹配日志标签和字段。 示例: ``` schema_config: configs: - from: 2022-01-01 store: boltdb object_store: filesystem schema: v11 index: prefix: index_ period: 24h retention_policy: 24h max_look_back_period: 0s storage_config: boltdb: directory: /var/lib/loki/boltdb filesystem: directory: /var/lib/loki/chunks ``` 3. storage_config段 storage_config段用于配置Loki存储方式,包括数据存储路径、存储类型等。可以使用多种存储类型,如local、s3、gcs等。 示例: ``` storage_config: boltdb: directory: /var/lib/loki/boltdb filesystem: directory: /var/lib/loki/chunks ``` 4. ingester段 ingester段用于配置Loki的数据输入方式,包括文件输入、stdin输入、http输入等。可以配置多个输入方式。 示例: ``` ingester: lifecycler: address: 127.0.0.1 ring: kvstore: store: inmemory replication_factor: 1 heartbeat_timeout: 1m election_timeout: 10s retry_period: 5s startup_timeout: 5s chunk_idle_period: 5m chunk_retain_period: 30m max_transfer_retries: 0 fail_on_unhandled_request: false client: url: http://localhost:3100/api/prom/push ``` 5. querier段 querier段用于配置Loki的查询方式,包括查询语法、查询参数等。可以配置多个查询方式。 示例: ``` querier: query_range: max_samples: 50000000 query: max_concurrent: 20 cache: cache: max_size_items: 0 index: max_size_bytes: 0 ``` 6. compactor段 compactor段用于配置Loki的压缩方式,包括压缩周期、压缩方式等。可以配置多个压缩方式。 示例: ``` compactor: working_directory: /var/lib/loki/compactor shared_store: filesystem shared_storage_config: filesystem: directory: /var/lib/loki/compactor compaction: working_directory: /var/lib/loki/compactor shared_store: filesystem shared_storage_config: filesystem: directory: /var/lib/loki/compactor compaction_window: 1h ``` 7. ruler段 ruler段用于配置Loki的告警规则,包括告警条件、告警方式等。可以配置多个告警规则。 示例: ``` ruler: storage: type: local local: directory: /etc/loki/rules rule_path: /etc/loki/rules alertmanager_url: http://localhost:9093 ring: kvstore: store: inmemory replication_factor: 1 heartbeat_timeout: 1m election_timeout: 10s retry_period: 5s startup_timeout: 5s ``` 这些是Loki配置文件的主要部分,通过配置文件可以自定义Loki的各种配置项,满足不同的需求。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值