config.yaml73 lines · main
| 1 | # Promtail — file-based docker log discovery. |
| 2 | # |
| 3 | # Per DOCKER.md §1 we DO NOT touch the Docker daemon for log discovery |
| 4 | # or tailing. No docker_sd_configs, no docker.sock mount. Instead we |
| 5 | # read the json-file driver's output directly from |
| 6 | # /var/lib/docker/containers/*/*-json.log — same data, zero daemon load. |
| 7 | # |
| 8 | # Filtering to "only briven containers" can't be done off the container |
| 9 | # label (that would require asking the daemon). Instead we filter by |
| 10 | # the JSON `service` label that briven services emit on every log line |
| 11 | # via @briven/shared/observability. Non-briven containers don't produce |
| 12 | # that JSON shape, so their lines flow through with `service` absent and |
| 13 | # Loki queries naturally exclude them via the standard |
| 14 | # `{service=~"api|runtime|realtime|web|docs"}` selector. |
| 15 | |
| 16 | server: |
| 17 | http_listen_port: 9080 |
| 18 | grpc_listen_port: 0 |
| 19 | |
| 20 | positions: |
| 21 | filename: /tmp/positions.yaml |
| 22 | |
| 23 | clients: |
| 24 | - url: http://briven-loki:3100/loki/api/v1/push |
| 25 | |
| 26 | scrape_configs: |
| 27 | - job_name: docker-files |
| 28 | # Static targets + __path__ glob is the Promtail idiom for file-based |
| 29 | # discovery. No daemon involvement; Promtail tails the json files |
| 30 | # directly via inotify on the host bind-mount. |
| 31 | static_configs: |
| 32 | - targets: |
| 33 | - localhost |
| 34 | labels: |
| 35 | job: docker |
| 36 | __path__: /var/lib/docker/containers/*/*-json.log |
| 37 | pipeline_stages: |
| 38 | # Each line in *-json.log is wrapped by the docker json-file |
| 39 | # driver as: {"log":"<raw stdout line>\n","stream":"stdout","time":"..."}. |
| 40 | # First parse unwraps the docker envelope. |
| 41 | - json: |
| 42 | expressions: |
| 43 | output: log |
| 44 | stream: stream |
| 45 | time: time |
| 46 | - timestamp: |
| 47 | source: time |
| 48 | format: RFC3339Nano |
| 49 | - output: |
| 50 | source: output |
| 51 | - labels: |
| 52 | stream: |
| 53 | # Extract the container id from the file path so an operator can |
| 54 | # at least correlate a line back to a specific container without |
| 55 | # asking the daemon. |
| 56 | - regex: |
| 57 | source: filename |
| 58 | expression: '/var/lib/docker/containers/(?P<container_id>[a-f0-9]{12})' |
| 59 | - labels: |
| 60 | container_id: |
| 61 | # Now the wrapped `output` field holds the application's raw stdout. |
| 62 | # For briven services that's our @briven/shared/observability JSON |
| 63 | # shape; parse it to lift level/msg/service/env into labels. |
| 64 | - json: |
| 65 | expressions: |
| 66 | level: level |
| 67 | msg: msg |
| 68 | service: service |
| 69 | env: env |
| 70 | - labels: |
| 71 | level: |
| 72 | service: |
| 73 | env: |