How do I line up OpenTelemetry log records with OpenTelemetry metric series for one service?
Tares lines up OpenTelemetry logs and metrics for one service when both carry the same primary service label, filled from the service.name resource attribute. One read of that service then returns the log lines and the metric values merged on one clock. The otlp connector takes both signals over OTLP, so you set the label once and point your exporter at Tares.
How it works
The OpenTelemetry connector receives OTLP/HTTP logs, traces and metrics at POST /v1/{logs,traces,metrics}. One otlp source ingests every service. Resource attributes, such as service.name, become labels, so everything an OTel SDK or Collector exports correlates by service with no per-service setup.
The alignment comes from one rule: every source that should share a timeline carries the same primary label. For OpenTelemetry that label is service, read from service.name.
- A log record from the checkout service arrives with
serviceset to checkout. - A metric point from the checkout service arrives with
serviceset to checkout. - Because both carry the same primary
servicelabel, Tares puts them on one timeline for that service.
The AI SRE guide uses the same pattern. Its metric, log and alert sources are all keyed by the same service label, and a single read of one service returns metrics, logs and alerts merged on one clock. You can keep logs and metrics in one otlp source, or split them across two otlp sources. Either way, give each source the same primary service label.
Set it up
-
Start Tares locally.
tares up -
Create the otlp source. Ask a connected agent to “use tares to create an OTLP source keyed by service”, or go to Sources → Add source → otlp in the console. There is no required config. The
servicelabel is the natural key. You can also send the same object toPOST /api/sources.- name: otel connector: otlp config: labels: - { name: service, field: service, primary: true } -
If you want logs and metrics in separate otlp sources, create a second source with the same
labelsentry. Keepserviceas the primary label in both. -
Point your exporter at Tares. OTLP/HTTP sends logs and metrics to
/v1/logsand/v1/metricsunder the endpoint you set. For gRPC, install theotlp-grpcextra withpip install 'tares[otlp-grpc]'. The receiver then listens on port 4317. You can change that withTARES_OTLP_GRPC_PORT, or set it tooffto disable it.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 -
If your Tares has auth on, the exporter sends a Bearer Authorization header holding an ingest-scoped API key. Set it with the
OTEL_EXPORTER_OTLP_HEADERSenvironment variable. Without auth, no header is needed. -
Make sure your SDK or Collector sets
service.nameon both its logs and its metrics. A signal without it has noservicevalue, so it cannot join the service’s timeline. -
Verify. Recent events shows logs and metric points as they arrive. Explore lists your services under the
servicekey. Open one service to see its log lines and metric values together. -
To read the same timeline from an agent, start the MCP endpoint in a second terminal and connect your client.
tares mcpThen ask, for example, “Use tares: what happened to checkout in the last 15 minutes?”. The client reads the service’s correlated timeline and answers from it.
What you get
- One timeline per service, with log lines and metric values merged on one clock instead of two separate views to compare by hand.
- No per-service setup. A new service that exports OTLP with a
service.nameshows up under theservicekey in Explore on its own. - The same read for people and agents. You open the service in Explore, and a connected MCP client reads the same correlated evidence.
- A base for the rest of an incident workflow. Because the service label is shared, you can add other sources keyed by
service, such as Prometheus alerts or a deploy webhook, and they land on the same timeline. Triggers keyed byservicecan then wake an agent with that timeline, as the AI SRE guide shows.
When something else fits
- If your metrics come from a Prometheus server rather than an OTel pipeline, use the prometheus connector and key it by the same
servicelabel. It lines up with OTLP logs the same way. - If your logs come from a container rather than OTLP, the docker_logs connector also joins the same service timeline when it carries the same primary label.
- If you are only exporting traces and have no logs or metrics yet, the otlp source still receives them, but there is nothing to line up until a second signal arrives.