How does an AI SRE read logs from Docker containers while investigating high latency?
Tares tails a running container’s logs with the docker_logs connector, labels each line by service, and puts those lines on the same per-service timeline as your metrics and alerts. When a latency alert fires, the agent reads that one timeline and sees the log lines from the same window as the alert. You set it up by pointing a source at the container and giving it a primary service label.
How it works
The Docker logs connector tails a running container’s logs and stores one event per line. Every line is kept by default, and you can narrow that with optional regex filters.
The service label is what ties the logs to the rest of your evidence. In the AI SRE setup, the log source, the metrics source and the alerts source all carry the same service label. Tares merges them into one timeline per service on one clock.
The flow during a latency incident looks like this:
- Your alerting rule, such as a
HighLatencyrule in Prometheus, fires and Tares ingests the alert event. - A trigger watching the sources, keyed by
service, fires on that alert event and wakes an agent. - The agent reads the correlated timeline for that service. It gets the alert, the latency metrics and the container’s log lines side by side, not three separate queries.
- The agent writes its finding back onto the service’s timeline, so the next investigation starts from that conclusion.
You can also pull instead of waiting for a trigger. A connected MCP client asks about the service, and Tares answers from the same correlated read.
Set it up
-
Install Tares and start it. Tares needs access to the Docker daemon, so run
taresdon the host, or mount the Docker socket and include the Docker CLI in the image.uv tool install tares # or: brew install glassflow/tap/tares tares up -
Add the source. In the console go to Sources, Add source, docker_logs and set
containerto the container or compose service name. Discover lists the running containers to pick from. You can also ask a connected agent to find your running containers and ingest the api-server’s logs. It scans withdiscover_docker, dry-runs withtest_source, then callscreate_source. -
Label the source by service. Give it a primary label named
service, and use the same label name on your metrics and alerts sources:- 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 } -
If the container runs under Compose without a fixed
container_name, setcontainerto the service name and addcompose_file. Use an absolute path, or one relative to where the daemon runs, so the tail follows restarts. -
Filter noisy lines if you need to.
matchkeeps only lines that match a regex, for exampleERROR|WARN.dropskips lines that match a regex, for exampleHTTP/1.1"to drop access logs. Be careful withdropwhen you investigate latency, because request logs often carry the timing evidence.label_patterntakes a regex with named groups and turns them into per-line label context. -
Verify. Open the source in the console. Recent events shows lines on the next poll. If nothing arrives, check that
taresdcan rundocker logsfor that container. -
Connect your agent. Start the MCP endpoint in a second shell, then point your client at it:
tares mcpThen ask: what happened to api-server in the last 15 minutes? The client reads the correlated timeline for that service, logs included.
-
Add the other two signals with the same
servicelabel: a Prometheus metrics source for latency such as p99, and an alerts source for what your rules fire. Then add a trigger over the three sources, keyed byservice, so a latency alert wakes the agent.
What you get
- Container log lines for a service sit on the same timeline as its latency metrics and alerts, so the agent reads them in the same window as the alert.
- Each line is one event, labeled by service, so a slow
api-servershows its own logs and not those of every container. - A trigger can wake an agent the moment the alert lands, or you can ask a connected MCP client on demand. Both read the same evidence.
- The agent’s conclusion is written back to the timeline, so the next latency investigation starts from the last finding.
- Filters keep the timeline readable:
matchfor the lines you want,dropfor the lines you do not.
When something else fits
- If your logs already flow through an OpenTelemetry pipeline, the OTLP connector is the better fit than tailing individual containers.
- If you only want a narrow slice, such as errors and warnings, keep the docker_logs source but set
matchso the timeline holds only those lines.