SigNoz Cloud - This page is relevant for SigNoz Cloud editions.
Self-Host - This page is relevant for self-hosted SigNoz editions.

Collecting Docker Logs

Overview

Docker writes container output to JSON log files on the host and daemon events to journald or syslog. This guide covers collecting both with an OpenTelemetry Collector.

Prerequisites

  • Docker Engine 20.10+ installed and running
  • Administrative access to the Docker host
  • OpenTelemetry Collector installed

Setup

Step 1. Update Collector configuration

Two approaches for collecting container logs, pick one:

  • filelog: tails all container log files under a single glob. Simpler setup. Requires only read access to /var/lib/docker/containers.
  • receiver_creator + docker_observer: spawns one receiver per container by watching the Docker socket. Sets container.name and container.image.name automatically with no regex.

Get your Collector's container ID so you can exclude its own logs:

docker inspect opentelemetry-collector --format='{{.Id}}'

Add to your config.yaml, replacing <OTEL_COLLECTOR_CONTAINER_ID> with that ID:

config.yaml
receivers:
  filelog/docker:
    include: [/var/lib/docker/containers/*/*-json.log]
    exclude:
      - /var/lib/docker/containers/<OTEL_COLLECTOR_CONTAINER_ID>/*
    poll_interval: 200ms
    start_at: end
    include_file_name: false
    include_file_path: true
    operators:
      - id: container-parser
        type: container
        format: docker
        add_metadata_from_filepath: false
      - id: extract-container-id
        type: regex_parser
        parse_from: attributes["log.file.path"]
        regex: '/var/lib/docker/containers/(?P<container_id>[a-f0-9]{64})/'
        on_error: send
      - id: move-container-id
        type: move
        from: attributes.container_id
        to: resource["container.id"]
        if: '"container_id" in attributes'
      - id: remove-filepath
        type: remove
        field: attributes["log.file.path"]
      - id: extract-service-name
        type: regex_parser
        parse_from: body
        regex: '"service\.name":\s*"(?P<svc>[^"]+)"'
        if: 'body matches "service\\.name"'
        on_error: send
      - id: set-service-name
        type: move
        from: attributes.svc
        to: resource["service.name"]
        if: '"svc" in attributes'

processors:
  memory_limiter:
    check_interval: 1s
    limit_mib: 4000
    spike_limit_mib: 800
  resourcedetection:
    detectors: [env, system]
    timeout: 5s
    system:
      hostname_sources: [os]
  transform/docker-meta:
    log_statements:
      - context: resource
        statements:
          - set(attributes["container.runtime"], "docker")
  batch:
    send_batch_size: 1024
    send_batch_max_size: 2048
    timeout: 10s

service:
  pipelines:
    logs:
      receivers: [filelog/docker]
      processors: [memory_limiter, resourcedetection, transform/docker-meta, batch]
      exporters: [otlp]

What each operator does:

  • exclude: Stops the Collector from ingesting its own logs.
  • include_file_path: Keeps log.file.path in the entry so the next operator can read the container ID.
  • extract-container-id / move-container-id: Reads the 64-char container ID from the file path and sets it as resource["container.id"].
  • remove-filepath: Drops log.file.path after extraction.
  • extract-service-name / set-service-name: Runs only when body matches service.name. Pulls the value into resource["service.name"] and skips all other logs.
  • resourcedetection: Adds host.name and OS info to every log entry.
  • transform/docker-meta: Sets container.runtime = "docker" on the resource for runtime filtering in SigNoz.

format: docker matches Docker's JSON log driver. The container operator also supports cri-o and containerd.

Step 2. Start the Collector

docker stop opentelemetry-collector
docker rm opentelemetry-collector

docker run --name opentelemetry-collector \
  --restart unless-stopped \
  --detach \
  --user 0:0 \
  --pid host \
  --network host \
  -v /var/lib/docker/containers:/var/lib/docker/containers:ro \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v /proc:/hostfs/proc:ro \
  -v /sys:/hostfs/sys:ro \
  -v /:/hostfs:ro \
  -v "$(pwd)/config.yaml":/etc/otelcol-contrib/config.yaml \
  -e HOST_PROC=/hostfs/proc \
  -e HOST_SYS=/hostfs/sys \
  -e HOST_ROOT=/hostfs \
  otel/opentelemetry-collector-contrib:latest

Validate

Generate some test logs:

docker run --rm alpine sh -c 'for i in $(seq 1 10); do echo "Test log entry $i"; sleep 1; done'

Open Logs Explorer in SigNoz. The test log lines from the Alpine container appear within seconds.

Docker container logs visible in SigNoz
Docker container logs visible in SigNoz

Next Steps

  • Parse log fields: dockerd writes structured log format (level=info msg="..."). Use the Logs Pipeline to extract fields like level, msg, and container into attributes for filtering and alerting.
  • Set up alerts: Create log-based alerts to catch errors from dockerd.
  • Explore dashboards: View container metrics alongside these logs with the Docker metrics dashboard.

Troubleshooting

No container logs appearing

  1. Check that Docker container log files exist and are readable:
ls -la /var/lib/docker/containers/
  1. Verify the Collector container can read the mounted log directory:
docker run --rm \
  -v /var/lib/docker/containers:/var/lib/docker/containers:ro \
  alpine ls /var/lib/docker/containers/
  1. Check the Collector logs for errors:
docker logs opentelemetry-collector | grep -i error

No Docker daemon logs appearing

  1. Confirm where Docker stores daemon logs on your host:
sudo journalctl -u docker.service -n 20
sudo tail -n 20 /var/log/syslog
sudo tail -n 20 /var/log/messages
  1. For the journald receiver: verify the Collector can access journalctl and the journal directory. See Collecting systemd logs (journald) for container requirements.

  2. For the syslog path: check your syslog forwarder configuration in Collecting Syslogs via OpenTelemetry Collector.

Get Help

If you need help with the steps in this topic, please reach out to us on SigNoz Community Slack.

If you are a SigNoz Cloud user, please use in product chat support located at the bottom right corner of your SigNoz instance or contact us at cloud-support@signoz.io.

Last updated: May 7, 2026

Edit on GitHub

Was this page helpful?

Your response helps us improve this page.