Access logs inside docker container

how to configure filebeat to ship logs inside the docker container running separately in same machine

You'll have your container logs at: /var/lib/docker/containers/

Mount this path to some directory in your container ( -v /var/lib/docker/containers:usr/share/filebeat/dockerlogs) when you are deploying a filebeat container and then give use this path to configure your filebeat.

Here's the sample config file:

- type: log
  enabled: true
    - /usr/share/filebeat/dockerlogs/*/*.log
  encoding: plain
    document_type: jenkins_container_log
  registry: /usr/share/filebeat/data/registry
  include_lines: ['failed']
  json.keys_under_root: true
  json.add_error_key: true
  json.message_key: log

  name: "filebeat"
  pattern: "filebeat-*"
    index.number_of_shards: 1
    index.number_of_replicas: 1
  hosts: ["xxx:9200"]
  index: "filebeat-%{[fields.document_type]}-%{+yyyy.MM.dd}"

my application is running as container and I want to run filebeat as a different container. do I need to mount my container logs for eg: /var/log/supervisor/app.log(inside the container) on the host.

I think you'll already have container logs on host in /var/lib/docker/containers. Mount this path to some directory on filebeat container.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.