How do I pair Alertmanager alert groups with logs from Docker containers for an AI SRE?
Tares pairs Alertmanager alerts with Docker container logs when both sources carry the same service label, so they land on one timeline. You create an alertmanager source and a docker_logs source, key both by service, and an agent reads the firing alert next to the log lines from the same window. The AI SRE guide shows the full wiring around it, including triggers and agents.
How it works
Tares builds one timeline per entity key. Sources that carry the same key value are merged on one clock, so an alert and a container’s log lines sit side by side.
- Alertmanager side. The
alertmanagerconnector is a push receiver. Alertmanager has already grouped, deduped and tracked firing to resolved. It POSTs a batch, and Tares fans thealertsarray out into one event per alert. The event type is the alert name, the text is its summary, and the alert labels become Tares labels plus astatusoffiringorresolved. The full alert, includingfingerprint, stays in the payload. - Key derivation. The entity key is taken from a label in this order:
namespace,service,job,instance. If your alerts carrynamespace, that label wins. Setkey_labeltoserviceso the alert keys onserviceinstead. - Docker side. The
docker_logsconnector tails a running container’s logs, one event per line. A primary label with a constant value, such asserviceset toapi-server, keys every line. - The match. The alert’s
servicelabel value and the log source’sservicevalue must be identical, for exampleapi-serveron both.
The Alertmanager connector is a push source, so the sender is Alertmanager. When Tares has auth on, Alertmanager sends a Bearer Authorization header holding an ingest-scoped API key. Without auth you need no header. The Docker connector is polled, so Tares reads from the Docker daemon directly. Run taresd on the host, or mount the Docker socket and include the Docker CLI in the image.
Set it up
-
Start Tares and open the console. Install it with
uv tool install taresorbrew install glassflow/tap/taresfirst if you have not.tares up -
Create the Alertmanager source under Sources, Add source, Alertmanager alerts. You can also ask a connected agent to create it and give you the webhook URL. The source page shows a receiver block with the ingest URL filled in. Add it to your
alertmanager.ymland reload Alertmanager.receivers: - name: tares webhook_configs: - url: http://localhost:8787/ingest/<ingest_key> send_resolved: true route: receiver: tares -
Make sure your alert rules attach a
servicelabel. In the Alertmanager source, setkey_labeltoserviceso it overrides thenamespacedefault.- name: alerts connector: alertmanager config: key_label: service -
Create the Docker source under Sources, Add source, docker_logs. Set
containerto the container name fromdocker ps, or to the Compose service name pluscompose_fileso the tail follows restarts. Give it a primaryservicelabel whose constant matches the alert’sservicevalue.- 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 } -
Verify the alert path by sending a test batch to the ingest endpoint, then open Recent events. Fields shows the alert labels, so you can confirm which one Tares keys on.
curl -X POST http://localhost:8787/ingest/<ingest_key> \ -H 'Content-Type: application/json' \ -d '{"alerts":[{"status":"firing","labels":{"alertname":"PostgresDown","severity":"critical","namespace":"prod"},"annotations":{"summary":"Postgres is down"},"startsAt":"2024-01-01T00:00:00Z"}]}' -
Verify the log path. Recent events on the Docker source shows lines on the next poll. If nothing arrives, check that
taresdcan rundocker logsfor that container. -
Open Explore, pick your service, and check that alerts and log lines appear on one timeline. To let an agent read it, start the MCP endpoint with
tares mcp, connect your client, and ask what happened to the service in the last 15 minutes.
What you get
- One timeline per service. A firing alert shows up with the log lines from the same window, on the same clock, instead of in two tools.
- Resolved state included. With
send_resolved: true, aresolvedevent lands on the timeline when the alert clears. - Alertmanager stays in charge. Alertmanager keeps owning grouping, silencing and routing. Tares records what it pushes and correlates it with your logs, with no re-thresholding.
- Less noise in the logs. Use the
matchanddropregex filters on the Docker source to keep only lines likeERROR|WARN, or to skip access logs, so the timeline carries the lines that matter. - A base for triggers and agents. A trigger over both sources, keyed by
service, can wake an agent when an alert event arrives. The agent then reads one correlated timeline and writes its finding back for the next investigation. The AI SRE guide walks through that loop end to end.
When something else fits
- If you want Tares to read alerts that Prometheus rules fire, without Alertmanager’s grouping and silencing, use the
prometheus_alertsconnector instead. Choosealertmanagerwhen you want grouping, silencing, resolved tracking and real-time delivery. - If your services do not run as local Docker containers, send logs through the OTLP connector, or through another source you key by the same
servicelabel.