Loki

v3.5.x

install using APT

  1. Add the Grafana Advanced Package Tool (APT) or RPM Package Manager (RPM) package repository following the linked instructions.
  2. Install Loki
apt-get update
apt-cache madison loki
apt-get install loki=3.5.8


S3 Single Store

config.yaml

auth_enabled: true  # true, 开启多租户模式

server:
  http_listen_port: 3100
  grpc_listen_port: 9096
  log_level: info
  grpc_server_max_concurrent_streams: 1000

common:
  #instance_addr: 127.0.0.1
  path_prefix: /loki  # `mkdir /loki && chown loki /loki` 在本地创建 /loki 目录,用于存储 index, cache. 
  replication_factor: 1
  ring:
    kvstore:
      store: inmemory

query_range:
  results_cache:
    cache:
      embedded_cache:
        enabled: true
        max_size_mb: 100

limits_config:
  metric_aggregation_enabled: true

schema_config:
  configs:
    - from: 2020-10-24
      store: tsdb
      object_store: s3  # s3
      schema: v13
      index:
        prefix: index_
        period: 24h

storage_config:
 tsdb_shipper:
   active_index_directory: /loki/index
   cache_location: /loki/index_cache
   cache_ttl: 24h    # Can be increased for faster performance over longer query periods, uses more disk space
 aws:
   s3: s3://<region>/<bucket_name>
   s3forcepathstyle: true
   # 如果部署在 ec2, 推荐使用 `EC2 instance role`
   access_key_id: <access_key_id>
   secret_access_key: <secret_access_key>


附加以下权限的策略

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "LokiStorage",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::<bucket_name>",
                "arn:aws:s3:::<bucket_name>/*"
            ]
        }
    ]
}


Promtail

# usermod -aG docker promtail
最后修改日期: 31 12 月, 2025

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。