grafana-loki搭建类似ELK/EFK轻量级日志监控系统

loki进行日志聚合处理 类似elk中的es
promtail是日志收集,类似elk中的logstash filebeat等,如果是只收集docker容器的日志则可以用loki的docker plugin替代
grafana是日志显示,类似elk中的kibana,可以通过各种标签和表达式过滤显示日志

一、采用docker-compose部署Loki、grafana、promtail

version: "3"
 
networks:
  loki:
 
services:
  loki:
    image: grafana/loki:latest
    container_name: loki
    restart: always
    environment:
      - TZ=Asia/Shanghai
      - LANG=zh_CN.UTF-8
    ports:
      - "3100:3100"
    volumes:
      - ./loki:/etc/loki:rw
    command: -config.file=/etc/loki/local-config.yaml
    networks:
      - loki
 
  grafana:
    image: grafana/grafana:latest
    restart: always
    container_name: grafana
    environment:
      - TZ=Asia/Shanghai
      - LANG=zh_CN.UTF-8
    ports:
      - "3000:3000"
    volumes:
      - ./grafana/config:/etc/grafana:rw
    networks:
      - loki
 
  # 非必要,日志采集器,默认配置为:采集当前机器/var/log目录的日志发送到loki
  promtail:
    image: grafana/promtail:latest
    container_name: promtail
    restart: always
    environment:
      - TZ=Asia/Shanghai
      - LANG=zh_CN.UTF-8
    volumes:
      - ./promtail:/etc/promtail:rw
      - /var/log:/var/log
    command: -config.file=/etc/promtail/config.yml
    

你可能感兴趣的:(Docker,docker,elasticsearch)