简易docker日志收集

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
version: "2"
services:
  logspout:
    image: gliderlabs/logspout:latest
    networks:
      - logging
    volumes:
      - /etc/hostname:/etc/host_hostname:ro
      - /var/run/docker.sock:/var/run/docker.sock
    environment: 
      RAW_FORMAT: '{ "container" : "{{ .Container.Name }}", "labels": {{ toJSON .Container.Config.Labels }}, "timestamp": "{{ .Time.Format "2006-01-02 15:04:05.999999999" }}","message": {{ toJSON .Data }} }'
    command: raw://docker-log-collection:8080 
    cpu_shares: 200  #限制CPU使用份额权重,默认1024
    mem_limit: 600m  #内存限制600M
    memswap_limit: 800m #内存+swap限制800M 
  grafana:
    image: grafana/grafana
    restart: on-failure
    ports:
      - "6102:3000"
    networks: 
      - logging 
    cpu_shares: 200  #限制CPU使用份额权重,默认1024
    mem_limit: 600m  #内存限制600M
    memswap_limit: 800m #内存+swap限制800M 
  influxdb-logs:
    image: influxdb:1.8
    restart: on-failure
    volumes: 
      - "/data/influxdb-logspout:/var/lib/influxdb" 
    labels:
      - "logs.Ignore=true"   
    networks:
      - logging
    cpu_shares: 200  #限制CPU使用份额权重,默认1024
    mem_limit: 600m  #内存限制600M
    memswap_limit: 800m #内存+swap限制800M 
  docker-log-collection:
    image: comll1024/docker-log-collection:1.0.8.20210621
    labels:
      - "logs.Ignore=true"
    networks: 
      - logging
    cpu_shares: 200  #限制CPU使用份额权重,默认1024
    mem_limit: 600m  #内存限制600M
    memswap_limit: 800m #内存+swap限制800M 
     
networks:
  logging:
    driver: bridge
updatedupdated2021-10-222021-10-22