Docker部署Grafana Loki日志收集系统

2023-05-16

官方参考文档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 端口映射

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Docker部署Grafana Loki日志收集系统 的相关文章

随机推荐