Skip to Content

How do I line up logs from Docker containers with OpenTelemetry metric series for one service?

Tares lines them up when both sources carry the same primary service label, so one read of the service returns the container log lines and the OpenTelemetry metric values on one clock. The docker_logs source gets a constant service value, and the otlp source reads its service label from resourceAttributes.service.name. Use the same service value on both and the logs and metrics land on one timeline for that service.

How it works

Tares correlates by label, not by connector. Every source that carries the same primary service label feeds one timeline per service, which is the single read an agent works from. The AI SRE guide builds its metrics, logs and alerts timeline the same way.

The two sources get their label differently:

  • Docker logs. The docker_logs connector tails one running container, one event per line. You name the service with a constant label, because a container’s log lines carry no service name of their own.
  • OpenTelemetry metrics. The otlp connector receives logs, traces and metrics at /v1/logs, /v1/traces and /v1/metrics. One otlp source ingests every service. The service label comes from the resource attribute service.name, written as the path resourceAttributes.service.name.

OTLP events have no bare service field, so a label that reads field: service gets no value from an OTLP event. Always use the full path. Mark the service label primary on both sources, and make the constant on the Docker source equal to the service.name your application exports. When the values match, the two streams join under one service.

Set it up

  1. Start Tares and open the console. Run tares up and go to Sources → Add source. The taresd daemon needs access to the Docker daemon, so run it on the host, or mount the Docker socket and include the Docker CLI in the image.
tares up
  1. Add the Docker logs source. Set container to the container name from docker ps. If the container runs under Compose, add compose_file so the tail follows restarts. Set the constant to the value your app exports as service.name, here api-server.
- 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 }
  1. Add the OTLP source. There is no required config, only the label. One source covers every service you export.
- name: otel connector: otlp config: labels: - { name: service, field: resourceAttributes.service.name, primary: true }
  1. Point your exporter at the daemon. Use OTLP/HTTP on port 8787, or gRPC on port 4317 if you installed the otlp-grpc extra. Make sure the app sets service.name to the same value as the Docker constant. On a secured instance (tares up --auth), the exporter sends an ingest-scoped API key as a Bearer Authorization header. That header is needed only when Tares has auth on.
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:8787 # OTLP/HTTP → /v1/{logs,traces,metrics} # or gRPC (otlp-grpc extra): OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
  1. Verify each source. On the Docker source, Recent events shows lines on the next poll. If nothing arrives, check that taresd can run docker logs for that container. On the OTLP source, Recent events shows metric points as they arrive, and Explore lists your services under the service key. Open the service in Explore to see the log lines and metric values merged.

  2. Repeat step 2 for each additional container, with its own constant service value. The single otlp source already handles every service.

What you get

  • One timeline per service, with Docker log lines and OpenTelemetry metric points merged on one clock in Explore.
  • One read per service for a connected agent. Ask it what happened to api-server in the last 15 minutes and it answers from the correlated read, not from two separate tools.
  • No per-service setup on the OTLP side. A new service that exports service.name shows up under the service key without a new source.
  • A base you can extend. Add alerts or a deploy webhook with the same service label and they join the same timeline.

When something else fits

  • If your logs already travel through your OpenTelemetry pipeline, send them to the otlp connector too. The same resourceAttributes.service.name label then covers logs and metrics in one source.
  • If your metrics live in a Prometheus server rather than an OTel pipeline, use the prometheus connector and read service from the metric labels, as the AI SRE guide does.

Still stuck? Get help

Last updated on