Skip to content

Instantly share code, notes, and snippets.

@lucj
Created January 7, 2021 09:50
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lucj/0c828c76c40b14b7265a64780863f5f5 to your computer and use it in GitHub Desktop.
Save lucj/0c828c76c40b14b7265a64780863f5f5 to your computer and use it in GitHub Desktop.
fluent-bit / loki / grafana on Docker Swarm
version: '3.8'
configs:
loki-conf:
file: ./loki.conf
fluent-bit-conf:
file: ./fluent-bit.conf
networks:
monitoring:
external: true
name: mon_monitoring
volumes:
loki-data:
services:
loki:
image: grafana/loki:2.0.0
networks:
- monitoring
volumes:
- loki-data:/loki
configs:
- source: loki-conf
target: /etc/loki/local-config.yaml
fluent-bit:
image: fluent/fluent-bit:1.6.6
configs:
- source: fluent-bit-conf
target: /fluent-bit/etc/fluent-bit.conf
deploy:
mode: global
environment:
- LOKI_URL=http://loki:3100/loki/api/v1/push
networks:
- monitoring
volumes:
- /var/lib/docker/containers:/var/lib/docker/containers
grafana:
image: grafana/grafana:7.3.3
deploy:
replicas: 1
networks:
- monitoring
ports:
- 3030:3000
[SERVICE]
Flush 10
Log_Level error
Daemon off
Parsers_File parsers.conf
[INPUT]
Name tail
Path /var/lib/docker/containers/*/*.log
Parser docker
Refresh_Interval 10
Mem_Buf_Limit 10MB
Skip_Long_Lines On
[FILTER]
name grep
match *
regex log service
[FILTER]
Name parser
Match *
Key_Name log
Parser json
[OUTPUT]
name loki
match *
host loki
labels job=fluentbit, $service
auth_enabled: false
server:
http_listen_port: 3100
log_level: warn
ingester:
lifecycler:
address: 127.0.0.1
ring:
kvstore:
store: inmemory
replication_factor: 1
final_sleep: 0s
chunk_idle_period: 5m
chunk_retain_period: 30s
schema_config:
configs:
- from: 2020-05-15
store: boltdb
object_store: filesystem
schema: v11
index:
prefix: index_
period: 168h
storage_config:
boltdb:
directory: /loki/index
filesystem:
directory: /loki/chunks
limits_config:
enforce_metric_name: false
reject_old_samples: true
reject_old_samples_max_age: 168h
@perfalle
Copy link

perfalle commented Sep 3, 2023

How do you get metadata of the container log, like container name or pod name?
The log files only show the docker id (in the path and file name).

@lucj
Copy link
Author

lucj commented Sep 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment