Openhab docker container logs into grafana

So one night later i made it. Indeed no openhab topic but maybe helps someone.

First I had to add the logging to each container

    logging:
      driver: "json-file"
      options: 
        tag: "{{.Name}}"

Then I missed to map the docker logs into my promtail container:

  promtail:
    image: grafana/promtail:2.8.5
    container_name: promtail
    volumes:
      - /var/lib/docker/containers:/var/log/docker/containers:ro  

And at least i had to change the promtail config:

## docker logs
- job_name: containers
  static_configs:
  - targets:
      - localhost
    labels:
      job: containerlogs
      __path__: /var/log/docker/containers/*/*log
  pipeline_stages:
  - json:
      expressions:
        output: log
        stream: stream
        attrs:
  - json:
      expressions:
        tag:
      source: attrs
  - regex:
      expression: (?P<container_name>(?:[^|]*[^|]))
      source: tag
  - timestamp:
      format: RFC3339Nano
      source: time
  - labels:
      # tag:
      stream:
      container_name:
  - output:
      source: output

And tadaaa, all container logs are available within loki :slight_smile:

So now i can go on with analyzation of openhab keeps crashing :face_with_monocle: