Generate metrics from logs using the count connector

domain: github.com/open-telemetry/opentelemetry-collector-contrib · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add the countconnector to your Collector config; connectors appear in both the exporters section of a source pipeline and the receivers section of a destination pipeline
  2. In the logs pipeline set the count connector as an exporter: service.pipelines.logs.exporters: [count]; in the metrics pipeline set it as a receiver: service.pipelines.metrics.receivers: [count]
  3. Configure the count connector with a logs block; each entry defines a metric name, description, unit, and optional conditions (OTTL expressions) that filter which log records contribute to that counter
  4. Add an attributes list to the metric definition to group counts by log record attributes (e.g., http.status_code, service.name); the connector emits a separate data point per unique combination of attribute values
  5. Set match_type in conditions to strict or regexp; use OTTL conditions like severity_number >= SEVERITY_NUMBER_ERROR to count only error-level logs, or body =~ "payment.*failed" for pattern-based business event counts
  6. Wire the metrics pipeline to a Prometheus exporter or OTLP exporter to expose the generated metrics to your alerting system; alert on the generated counters using the same threshold logic you would apply to application-emitted metrics

Known gotchas

Related routes

Use the OTel Collector count connector to derive a request-count metric from log records without modifying the application
opentelemetry.io · 5 steps · unrated
Generate RED metrics from trace spans using the OTel Collector spanmetrics connector
opentelemetry.io · 6 steps · unrated
Generate span metrics from traces using the OTel Collector spanmetrics connector
opentelemetry.io · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans