How does an AI SRE read logs from Docker containers while investigating crash loops?
Tares tails a container’s logs with the docker_logs connector and labels them by service, so an agent reads log lines in the same window as the crash loop alert. Each log line becomes one event on that service’s timeline, next to its metrics and alerts. A trigger can wake an agent when the alert fires, or you can ask a connected agent to read the timeline on demand. For a Compose service, set compose_file so the tail follows container restarts.
How it works
The docker_logs connector tails a running container’s logs and stores one event per line. It keeps all lines by default, and you can narrow them with match and drop regex filters.
The connector needs access to the Docker daemon. Run taresd on the host, or mount the Docker socket and include the Docker CLI in the image.
The label is what puts logs and alerts in one window:
- You give the log source a primary
servicelabel, for example the constantapi-server. - Your metric and alert sources carry the same
servicelabel. - Tares merges everything with that label into one timeline per service, on one clock.
When a container crash loops, the alert for that service and the log lines it printed before each restart sit side by side. An agent reads that single timeline instead of querying the alert system and Docker separately.
There are two ways an agent gets there, both described in Build an AI SRE:
- Push: a trigger watches your sources keyed by
serviceand fires when an alert event arrives. It wakes an agent, which reads the correlated timeline and writes a finding back onto it. - Pull: a connected MCP client asks about the service, for example “what happened to api-server in the last 15 minutes?”. The client calls
readwith the service name and answers from the same correlated read.
If the container runs under Compose, compose_file makes the tail follow restarts. That matters in a crash loop, because the container is replaced again and again.
Set it up
-
Start Tares and make sure it can reach Docker. Run it on the host so
taresdhas access to the daemon.tares up -
Ask a connected agent to do the discovery for you:
Use tares to find my running containers and ingest the api-server’s logs.
The agent calls
discover_dockerto scan running containers and propose one source per candidate. It then dry-runs the source withtest_source, which tails a few lines, and callscreate_source. -
Or add the source by hand. Go to Sources → Add source → docker_logs, set
containerto the container or compose service name, and use Discover to pick from running containers. Save with this shape:- name: logs connector: docker_logs poll: 5s config: container: tares-demo-api-server # the container name (docker ps) labels: - { name: service, const: api-server, primary: true } -
Label by service. Use the same
servicelabel name on your metric and alert sources, so all of them land on one timeline. If the label value varies per line,label_patterntakes a regex with named groups and turns them into per-line label context. -
For a Compose container without a fixed
container_name, setcontainerto the service name and addcompose_file, an absolute path or one relative to where the daemon runs. This lets the tail follow restarts. -
Trim the noise if you need to.
matchkeeps only lines matching a regex, such asERROR|WARN.dropskips lines matching a regex, such asHTTP/1.1"to remove access logs. -
Verify. Open the source in the console. Recent events shows lines on the next poll. If nothing arrives, check that
taresdcan rundocker logson that container, since that is the access the connector uses. -
To investigate interactively, start the MCP endpoint in a second shell and point your client at it. Then ask about the service.
tares mcp
The Docker logs connector page has the full field table.
What you get
- Every log line from the container as its own event, labeled by service.
- One timeline per service in Explore, where the crash loop alert and the lines around it appear on the same clock.
- An agent that starts from evidence. A trigger-woken agent reads the correlated timeline and ties its conclusion to specific log lines. A connected MCP client gets the same read on demand.
- A finding written back onto the service’s timeline, so the next investigation of that service starts from the previous conclusion instead of from scratch.
- Control over volume, through
matchanddrop, so repeated startup errors stay readable.
When something else fits
- If your containers already ship logs through an OpenTelemetry pipeline, the OTLP connector fits better than tailing each container. Build an AI SRE lists it as the alternative for logs.
- If
taresdcannot reach the Docker daemon, for example because it runs somewhere with no socket access, use a connector that does not depend on Docker access.