日志监控系统 loki 配置文件详解

loki 配置文件详解

auth_enabled: false

server:
  http_listen_port: 3100 # http_listen_port: 配置HTTP监听端口号为3100。
  graceful_shutdown_timeout: 60s # 配置优雅停机的超时时间为60秒。
  http_server_read_timeout: 60s # 配置HTTP服务器读取超时时间为60秒。
  http_server_write_timeout: 60s # 配置HTTP服务器写入超时时间为60秒。

ingester: # 配置Loki的ingester部分,用于接收和处理日志数据。
  lifecycler: # 配置生命周期管理器,用于管理日志数据的生命周期。
    address: 10.0.0.8 # 配置生命周期管理器的地址
    ring: # 配置哈希环,用于将日志数据分配给不同的Loki节点
      kvstore: # 配置键值存储,用于存储哈希环的节点信息。
        store: inmemory # 配置存储引擎为inmemory,即内存中存储
      replication_factor: 1 # 配置复制因子为1,即每个节点只存储一份数据。
    final_sleep: 0s # 配置最终休眠时间为0秒,即关闭时立即停止。
  chunk_idle_period: 1h # 配置日志块的空闲时间为1小时。如果一个日志块在这段时间内没有收到新的日志数据,则会被刷新。
  max_chunk_age: 1h # 配置日志块的最大年龄为1小时。当一个日志块达到这个年龄时,所有的日志数据都会被刷新。
  chunk_target_size: 2048576 # 配置日志块的目标大小为2048576字节(约为1.5MB)。如果日志块的空闲时间或最大年龄先达到,Loki会首先尝试将日志块刷新到目标大小。
  chunk_retain_period: 30s # 配置日志块的保留时间为30秒。这个时间必须大于索引读取缓存的TTL(默认为5分钟)。
  max_transfer_retries: 0 # 配置日志块传输的最大重试次数为0,即禁用日志块传输。

schema_config: # 配置Loki的schema部分,用于管理索引和存储引擎。
  configs: # 配置索引和存储引擎的信息。
    - from: 2020-10-24 # 配置索引和存储引擎的起始时间。
      store: boltdb-shipper # 配置存储引擎为boltdb-shipper,即使用BoltDB存储引擎。
      object_store: filesystem # 配置对象存储引擎为filesystem,即使用文件系统存储。
      schema: v11 # 配置schema版本号为v11。
      index: # 配置索引相关的信息。
        prefix: index_ # 配置索引文件的前缀为index_。
        period: 24h # 配置索引文件的周期为24小时。

storage_config: # 配置Loki的存储引擎相关的信息。
  boltdb_shipper: # 配置BoltDB存储引擎的信息。
    active_index_directory: /tmp/loki/boltdb-shipper-active # 配置活动索引文件的存储目录为/tmp/loki/boltdb-shipper-active。
    cache_location: /tmp/loki/boltdb-shipper-cache # 配置BoltDB缓存文件的存储目录为/tmp/loki/boltdb-shipper-cache。
    cache_ttl: 240h # 配置BoltDB缓存的TTL为240小时。
    shared_store: filesystem # 配置共享存储引擎为filesystem,即使用文件系统存储。
  filesystem: # 配置文件系统存储引擎的信息,即日志数据的存储目录为/tmp/loki/chunks
    directory: /tmp/loki/chunks

compactor: # 配置日志压缩器的信息。
  working_directory: /tmp/loki/boltdb-shipper-compactor # 配置工作目录为/tmp/loki/boltdb-shipper-compactor。
  shared_store: filesystem # 配置共享存储引擎为filesystem,即使用文件系统存储。

limits_config: # 配置Loki的限制策略。
  reject_old_samples: true # 配置是否拒绝旧的日志数据。
  reject_old_samples_max_age: 168h # 配置拒绝旧的日志数据的最大年龄为168小时。
  ingestion_rate_mb: 64 # 配置日志数据的最大摄入速率为64MB/s。
  ingestion_burst_size_mb: 128 # 配置日志数据的最大摄入突发大小为128MB。
  max_streams_matchers_per_query: 100000 # 配置每个查询的最大流匹配器数量为100000。
  max_entries_limit_per_query: 50000 # 配置每个查询的最大条目限制为50000。

chunk_store_config: # 配置日志数据的存储策略。
  #  max_look_back_period: 1440h
  max_look_back_period: 240h # 配置最大回溯时间为240小时。

table_manager: # 配置Loki的表管理器。
  retention_deletes_enabled: true # 配置是否启用保留期删除。
  #  retention_period: 1440h
  retention_period: 240h # 配置保留期为240小时。

ruler:
  storage:
    type: local
    local:
      directory: /tmp/loki/rules
  rule_path: /tmp/loki/rules-temp
  alertmanager_url: http://10.0.0.8:9093
  ring:
    kvstore:
      store: inmemory
  enable_api: true
#ruler:
#  storage:
#    type: local
#    local:
#      directory: /tmp/loki/rules/
#  ring:
#    kvstore:
#      store: consul
##  rule_path: /tmp/loki/rules-temp
#  enable_api: true
#  enable_sharding: true
#  enable_alertmanager_v2: true
#  alertmanager_url: "http://10.0.0.8:9093"

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值