> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bronto.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker container logs with OpenTelemetry

> Collect stdout and stderr logs from Docker and Docker Compose containers with the OpenTelemetry Collector and forward them to Bronto for search and analysis.

Collect logs from Docker and Docker Compose containers with the OpenTelemetry Collector, reading the files written by Docker's default `json-file` logging driver. The same Collector can also forward traces and metrics from your apps — see [Connect OpenTelemetry Collector to Bronto](/agent-setup/open-telemetry).

## Prerequisites

* A Bronto account and API key ([how to create one](/Account-Management/API-Keys#create-a-new-api-key))
* Docker using the default [`json-file` logging driver](https://docs.docker.com/engine/logging/configure/) (logs at `/var/lib/docker/containers/*/*-json.log`)
* An [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/installation/) (recommended) or [Fluent Bit](https://docs.fluentbit.io/manual/installation/getting-started-with-fluent-bit) — run it as a container alongside your services

## Run the Collector

Add the Collector to your `docker-compose.yml` and give it read access to Docker's container log directory:

```yaml docker-compose.yml theme={"dark"}
services:
  otel-collector:
    image: otel/opentelemetry-collector-contrib:latest
    command: ["--config=/etc/otel/config.yaml"]
    volumes:
      - ./otel-config.yaml:/etc/otel/config.yaml:ro
      - /var/lib/docker/containers:/var/lib/docker/containers:ro
```

The Collector tails the container logs, unwraps Docker's JSON envelope, and ships to Bronto:

```yaml otel-config.yaml theme={"dark"}
receivers:
  filelog/docker:
    include:
      - /var/lib/docker/containers/*/*-json.log
    operators:
      - type: json_parser
    resource:
      service.name: <YOUR_DATASET_NAME>
      service.namespace: <YOUR_COLLECTION_NAME>

processors:
  batch:

exporters:
  otlphttp/brontologs:
    logs_endpoint: "https://ingestion.<REGION>.bronto.io/v1/logs"
    compression: gzip
    headers:
      x-bronto-api-key: <YOUR_API_KEY>

service:
  pipelines:
    logs:
      receivers: [filelog/docker]
      processors: [batch]
      exporters: [otlphttp/brontologs]
```

Set `<REGION>` to `eu` or `us`.

## What you will see in Bronto

Open [Search](https://app.bronto.io/search) and filter by `service.name`. Docker's `json-file` driver wraps each line as `{"log": "...", "stream": "stdout|stderr", "time": "..."}`; the `json_parser` operator promotes those into fields, so you get the container's message, the stream, and a timestamp. Bronto's [Custom Parser](/core-features/custom-parser) extracts further structure from the message body.

## Troubleshooting

* **No logs?** Confirm the driver is `json-file` (`docker inspect -f '{{.HostConfig.LogConfig.Type}}' <container>`) and that the Collector mounts `/var/lib/docker/containers` read-only.
* **Per-service datasets?** Run one Collector centrally with a `service.name` per environment, or route by container labels with an `attributes` processor.
* For general issues, see [OTel Collector troubleshooting](https://opentelemetry.io/docs/collector/troubleshooting/).

## Alternative: Fluent Bit

If you already run Fluent Bit, tail the container log files and forward them over HTTP. The `docker` multiline parser reassembles partial lines from the `json-file` driver:

```ini fluent-bit.conf theme={"dark"}
[INPUT]
    name              tail
    path              /var/lib/docker/containers/*/*-json.log
    multiline.parser  docker
    tag               docker

[OUTPUT]
    name        http
    match       docker
    host        ingestion.<REGION>.bronto.io
    port        443
    tls         on
    format      json_lines
    compress    gzip
    header      x-bronto-api-key    <YOUR_API_KEY>
    header      x-bronto-dataset    <YOUR_DATASET_NAME>
    header      x-bronto-collection <YOUR_COLLECTION_NAME>
```

Set **Format** to `json_lines`, not `json`. You can also point Docker's native [`fluentd` logging driver](https://docs.docker.com/engine/logging/configure/) at Fluent Bit. See [Connect Fluent Bit to Bronto](/agent-setup/fluent-bit) for installation.
