# Docker container logs

Collect the logs of every container on a Docker host and send them to Flowhawk, named by container.

Vector runs as one more container, reads the other containers' logs through the Docker socket, and posts them to Flowhawk. Your containers and their logging driver stay as they are.

## What you get

- Every container's logs in [Logs](https://flowhawk.dev/docs/signals#logs), next to your traces and metrics, searchable with the same query language (`severity>=WARN service=checkout "timeout"`), grouped into patterns or followed live.
- A log line that names a request path joins the [business flow](https://flowhawk.dev/docs/flows) of that route, so a failing checkout shows these logs on the checkout flow's page.
- A line that carries a trace id opens its trace.
- Alert on any search with **Alert on this**, and let the agent read these logs when it investigates an incident.

## Set it up

First create an ingest key: in the app, open **Settings > API keys** and pick **Services**. In the examples below, `KEY` stands for that key. Keep it out of your repository, like any other secret.

### 1. Write vector.toml

```
[sources.docker]
type = "docker_logs"

# Lines that are JSON become fields (level, message, trace_id...)
[transforms.parse]
type = "remap"
inputs = ["docker"]
source = '''
parsed, err = parse_json(.message)
if err == null && is_object(parsed) { . = merge(., object!(parsed)) }
'''

[sinks.flowhawk]
type = "http"
inputs = ["parse"]
uri = "https://api.flowhawk.dev/v1/logs/vector"
encoding.codec = "json"
auth.strategy = "bearer"
auth.token = "${FLOWHAWK_KEY}"
```

### 2. Run Vector next to your containers

```
docker run -d --name vector --restart unless-stopped \
  -e FLOWHAWK_KEY=KEY \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  -v "$PWD/vector.toml:/etc/vector/vector.toml:ro" \
  timberio/vector:latest-alpine --config /etc/vector/vector.toml
```

With Docker Compose, add the same as a service. Each container's logs are named after the container, so name containers after the services in them (`container_name: orders`).

## Check it arrived

Open **Logs** in the app and filter on the service. If nothing shows after a minute, [Help and troubleshooting](https://flowhawk.dev/docs/help) says why data can be refused (a wrong key, an empty balance) and how to see it.

## Common questions

### Can I skip some containers?

Yes. `exclude_containers = ["vector"]` or `include_labels = ["logs=flowhawk"]` in the source decides which are read.

### What about container CPU and memory?

Those come from an [OpenTelemetry Collector](https://flowhawk.dev/integrations/opentelemetry-collector) with the `docker_stats` receiver. Flowhawk has a ready-made Docker containers dashboard for them.

### And traces?

Add OpenTelemetry to the services in the containers ([language guides](https://flowhawk.dev/docs/languages)). Log lines that carry a trace id then open their trace.

## Related

[**Vector**Send any log Vector can read to Flowhawk with one http sink.](https://flowhawk.dev/integrations/vector-logs) [**Kubernetes monitoring**Pod logs, node and pod metrics and your services' traces from a Kubernetes cluster, with two Helm charts you may already know.](https://flowhawk.dev/integrations/kubernetes-monitoring) [**OpenTelemetry Collector**Send everything your OpenTelemetry Collector receives to Flowhawk, and collect host and container metrics on the way.](https://flowhawk.dev/integrations/opentelemetry-collector)

[Try it free for 14 days](https://app.flowhawk.dev/signup?trial=1) [Read the getting started guide](https://flowhawk.dev/docs/getting-started)

---

URL: https://flowhawk.dev/integrations/docker-logs
