How can an AI SRE match a jump in OpenTelemetry metric series to the lines in logs from Docker containers?
Tares lets an AI SRE line up a jump in OpenTelemetry metrics with Docker container log lines by giving both sources the same primary service label. The agent reads one window for that service, so it sees when the metric moved and when the log lines changed. You set up an otlp source for the metrics and a docker_logs source for the container, and Tares merges them on one timeline per service.
How it works
Tares correlates by label. Every source that carries the same primary service label lands on one timeline for that service, with metrics and logs on one clock. The AI SRE guide builds its agent from exactly this read.
Two sources feed the timeline here:
- OpenTelemetry metrics. The OpenTelemetry connector receives OTLP/HTTP logs, traces and metrics. One source ingests every service, and resource attributes such as
service.namebecome labels. Theservicelabel reads its value fromresourceAttributes.service.name. OTLP events have no bareservicefield, so a label withfield: servicegets no value. - Docker container logs. The Docker logs connector tails a running container’s logs, one event per line. It has no resource attributes, so you give the source a constant
servicelabel.
Mark the service label primary on both sources, and make the constant on the Docker source equal the service.name your app exports. A metric point for api-server and a log line from the api-server container then sit on the same service timeline.
When an agent reads that service, it gets the window as one correlated timeline. It can compare the time the metric series moved with the time the log lines changed, such as a burst of errors or a new message.
Set it up
-
Install Tares and start it locally. You can also install with
pipx install taresorbrew install glassflow/tap/tares.uv tool install tares tares up -
Open the console at
http://127.0.0.1:8787, go to Sources → Add source, and create both sources. Or ask a connected agent to create them. The two definitions look like this. Note that theservicelabel is primary on both:- name: otel connector: otlp config: labels: - { name: service, field: resourceAttributes.service.name, primary: true } - 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 } -
Make sure the value of
service.namein your OpenTelemetry resource matches the constant on the Docker source. In this example both areapi-server. -
Point your exporter at Tares. For OTLP/HTTP the metrics go to
/v1/metricson the daemon:OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8787 # OTLP/HTTP → /v1/{logs,traces,metrics} # or gRPC (otlp-grpc extra): OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317If Tares has auth on, the exporter sends a Bearer Authorization header holding an ingest-scoped API key. Without auth you do not need it.
-
Check both sources. Open each one and look at Recent events: metric points appear for the otlp source and log lines appear on the next poll for the Docker source. If no lines arrive, check that
taresdcan rundocker logsfor the container. If the container runs under Compose without a fixed container name, setcontainerto the service name and addcompose_file. -
Start the MCP endpoint in a second terminal so your agent can read the timeline:
tares mcpConnect your MCP client as the AI SRE guide describes, then ask:
Use tares: what happened to api-server in the last 15 minutes?
What you get
- One window per service. The metric points and the container log lines for
api-servercome back together on one clock, so the agent reads them side by side instead of querying two systems. - Timing you can act on. The agent sees when the metric series moved against when the log lines changed, and can tie the jump to specific lines.
- No per-service setup on the metric side. The otlp source ingests every service. A new service that exports
service.nameshows up under theservicekey in Explore. - The same read for pull and push. You can ask a connected client on demand, or have a trigger over these sources wake an agent. In both cases the agent works from the same correlated timeline.
- A timeline that gets smarter. When an agent writes a finding back, the next investigation of that service starts from it.
When something else fits
- If the logs already come through your OpenTelemetry pipeline, send them to the same otlp source instead of adding a docker_logs source. The
servicelabel then covers logs and metrics in one place. - If your metrics live in a Prometheus server rather than arriving over OTLP, use the Prometheus connector from the AI SRE guide and keep the same
servicekey. - If the container is not on a host where
taresdcan reach the Docker daemon, the Docker connector cannot tail it, so use another route for those logs.
Related
- Build an AI SRE
- How can an AI SRE match a jump in Prometheus metrics to the lines in OpenTelemetry log records?
- How can an AI SRE match a jump in Prometheus metrics to the lines in Grafana Loki logs?
- How can an AI SRE match a jump in Prometheus metrics to the lines in logs from Docker containers?
Still stuck? Get help