Docker部署Grafana Loki日志收集系统

官方参考文档icon-default.png?t=M85Bhttps://grafana.com/docs/loki/latest/installation/docker/

Docker部署loki

loki配置文件(二选一)

  • 使用命令下载loki-config.yaml,根据需要修改

    wget https://raw.githubusercontent.com/grafana/loki/v2.6.1/cmd/loki/loki-local-config.yaml -O loki-config.yaml

  • 或自己创建loki-config.yaml,根据需要修改

    auth_enabled: false
    ​
    server:
      http_listen_port: 3100
      grpc_listen_port: 9096
    ​
    common:
      path_prefix: /tmp/loki
      storage:
        filesystem:
          chunks_directory: /tmp/loki/chunks
          rules_directory: /tmp/loki/rules
      replication_factor: 1
      ring:
        instance_addr: 127.0.0.1
        kvstore:
          store: inmemory
    ​
    schema_config:
      configs:
        - from: 2020-10-24
          store: boltdb-shipper
          object_store: filesystem
          schema: v11
          index:
            prefix: index_
            period: 24h
    ​
    ruler:
      alertmanager_url: http://localhost:9093
    ​
    # By default, Loki will send anonymous, but uniquely-identifiable usage and configuration
    # analytics to Grafana Labs. These statistics are sent to https://stats.grafana.org/
    #
    # Statistics help us better understand how Loki is used, and they show us performance
    # levels for most users. This helps us prioritize features and documentation.
    # For more information on what's sent, look at
    # https://github.com/grafana/loki/blob/main/pkg/usagestats/stats.go
    # Refer to the buildReport method to see what goes into a report.
    #
    # If you would like to disable reporting, uncomment the following lines:
    #analytics:
    #  reporting_enabled: false

使用命令运行容器

docker run --name loki -d -v /mnt/config:/mnt/config -p 3100:3100 grafana/loki:2.6.1 -config.file=/mnt/config/loki-config.yaml

Docker部署promtail

Docker配置文件(二选一)

  • 使用命令下载promtail-config.yaml,根据需要修改

    wget https://raw.githubusercontent.com/grafana/loki/v2.6.1/clients/cmd/promtail/promtail-docker-config.yaml -O promtail-config.yaml

  • 或自己创建promtail-config.yaml,根据需要修改

    server:
      http_listen_port: 9080
      grpc_listen_port: 0
    ​
    positions:
      filename: /tmp/positions.yaml
    ​
    clients:
      - url: http://loki:3100/loki/api/v1/push
    ​
    scrape_configs:
    - job_name: system
      static_configs:
      - targets:
          - localhost
        labels:
          job: varlogs
          __path__: /var/log/*log

使用命令运行容器

docker run --name promtail -d -v /mnt/config:/mnt/config -v /var/log:/var/log --link loki grafana/promtail:2.6.1 -config.file=/mnt/config/promtail-config.yaml

其他说明:

docker命令

--name 指定镜像名

-d 后台运行

-v 挂载目录

-p 端口映射

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值