> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OTel Col Connectors

> Explains OpenTelemetry Collector connectors, their placement, use cases, and configuration examples for deriving, routing, aggregating, and forwarding telemetry without changing application code

Connectors in the OpenTelemetry Collector enable cross-pipeline telemetry flows and lightweight transformations without changing application SDKs. This article explains what connectors are, where they sit in Collector pipelines, why they’re useful, and how to configure common connectors: count, spanmetrics, servicegraph, routing, forward, sum, and exceptions. Each example uses YAML for the Collector configuration and includes typical use cases and wiring patterns.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/agenda-connectors-introduction-placement-usefulness.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=be83a57de6dda9ff68c081efcd421de0" alt="The image shows an agenda with four items related to connectors, covering their introduction, placement, usefulness, and configuration." width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/agenda-connectors-introduction-placement-usefulness.jpg" />
</Frame>

What is a connector?

* A connector acts as an exporter on a source pipeline and as a receiver on a target pipeline.
* This lets the Collector derive new telemetry (for example, metrics from traces) or route/fan out data without changing application or SDK code.
* Connectors are useful for SRE metrics (RED/SLIs), topology graphs, routing, aggregation, and error extraction.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/opentelemetry-collector-pipelines-setup.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=3b005e7706903e648a64c287b7fe2805" alt="The image illustrates an OpenTelemetry Collector setup, showing two pipelines—Traces and Metrics—connected by a connector. Each pipeline includes Receivers, Processors, and Exporters." width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/opentelemetry-collector-pipelines-setup.jpg" />
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Connectors bridge pipelines by appearing as an exporter on the source pipeline and as a receiver on the target pipeline. This allows the Collector to derive new telemetry (for example, metrics from spans) without changing application or SDK code.
</Callout>

Connector placement and flow

* A connector receives telemetry already processed by a pipeline, optionally performs computation (derive metrics, count, sum, build graphs), and emits data into another pipeline for further processing/export.
* Typical flow: receiver → processors → connector (acts as exporter) → metrics/other pipeline (connector acts as receiver) → exporters.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/data-pipeline-connectors-placement-diagram.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=1ebf83ecf5698f16be895bc884954da1" alt="The image illustrates the placement of connectors within a data pipeline, showing the flow from receivers to processors and exporters, and emphasizing the connector's role in emitting derived metrics." width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/data-pipeline-connectors-placement-diagram.jpg" />
</Frame>

Common use cases

* Fan-out / reuse telemetry across multiple pipelines.
* Derive metrics from traces (RED metrics, SLIs, latency histograms).
* Build service dependency graphs and detect unexpected edges.
* Conditionally route telemetry based on attributes.
* Aggregate counts or sums into time-series for KPIs.

Common connectors

* spanmetrics — derive latency, error, and rate metrics from spans.
* servicegraph — build service dependency/topology metrics.
* routing — OTTL rules to route telemetry to pipelines.
* count — convert span events/logs into simple counts.
* sum — aggregate numeric attributes into time-series.
* forward — merge/split pipelines without transforming telemetry.
* exceptions — extract exception data for logging/alerting.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/common-connectors-spanmetrics-servicegraph-routing-count.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=cb369d2c8938d00e32fb84894b5bf44a" alt="The image lists four common connectors: SpanMetrics, ServiceGraph, Routing, and Count, each with a brief description of their functions related to metrics and traces." width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/common-connectors-spanmetrics-servicegraph-routing-count.jpg" />
</Frame>

Connector comparison (quick reference)

| Connector    |                           Primary purpose | Typical source signal          | Example outcome                     |
| ------------ | ----------------------------------------: | ------------------------------ | ----------------------------------- |
| spanmetrics  | Derive RED metrics, histograms, exemplars | Traces                         | Latency histograms, error rates     |
| servicegraph |            Build service dependency graph | Traces                         | Service-to-service edge metrics     |
| routing      |         Route/fan-out based on OTTL rules | Any (resource/span/log/metric) | Environment-based pipelines         |
| count        |                      Count matched events | Spans / Logs                   | Time-series pulse metrics           |
| sum          |              Aggregate numeric attributes | Spans                          | KPI time-series (order totals)      |
| forward      |                     Merge/split pipelines | Any                            | Combined or branched pipelines      |
| exceptions   |                    Extract exception data | Traces (exceptions)            | Correlated logs with trace/span IDs |

***

## Count connector (example)

The Count connector converts span events or logs into simple time-series counts based on matching conditions. It operates as an exporter on the traces/logs pipeline and as a receiver on the metrics pipeline.

Example: count span events named "prodevent" coming from environment "prod" and emit metrics to the metrics pipeline, which exports to `debug`:

```yaml theme={null}
receivers:
  otlp:
    protocols:
      grpc: {}
      http: {}

exporters:
  debug: {}

connectors:
  count:
    spanevents:
      my.prod.event.count:
        description: "The number of span events from prod"
        conditions:
          - 'attributes["env"] == "prod"'
          - 'name == "prodevent"'

service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [count]
    metrics:
      receivers: [count]
      exporters: [debug]
```

How it works:

* Traces arrive via OTLP → processed → exported to `count`.
* The connector checks each span event against the `conditions`.
* Matches generate a metric `my.prod.event.count` emitted into the metrics pipeline and exported by `debug`.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/pulse-metrics-flowchart-count-connector.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=ec8d540efdf56dfee554c64c9bf25fe6" alt="The image is a flowchart illustrating a process for generating pulse metrics using a count connector, with data flowing from a &#x22;Spans/Logs Stream&#x22; through &#x22;conditions&#x22; to a &#x22;Time Series Output.&#x22;" width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/pulse-metrics-flowchart-count-connector.jpg" />
</Frame>

***

## SpanMetrics connector

SpanMetrics derives SRE-style metrics (rate, errors, latency histograms) and exemplars from spans. It is commonly used to produce RED metrics and latency histograms for Prometheus.

Example: receive traces via OTLP, apply spanmetrics with explicit histogram buckets, dimensions, and exemplars, and export to Prometheus:

```yaml theme={null}
receivers:
  otlp:
    protocols:
      grpc: {}
      http: {}

exporters:
  prometheus:
    endpoint: 0.0.0.0:8889

connectors:
  spanmetrics:
    histogram:
      explicit:
        buckets: [2ms, 8ms, 50ms, 100ms, 200ms, 500ms, 1s, 5s, 10s]
      dimensions:
        - name: http.method
        - name: http.status_code
      exemplars:
        enabled: true

service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [spanmetrics, otlp]
    metrics:
      receivers: [spanmetrics]
      exporters: [prometheus]
```

Use cases:

* SLIs and RED metrics (requests, error rates, durations).
* Latency histograms with exemplars for trace-level correlation.
* Error trend analysis by dimensions (status code, method).

***

## ServiceGraph connector

ServiceGraph computes a service dependency graph from trace spans, identifying client→service and service→service edges and generating related metrics to highlight hotspots or unexpected dependencies.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/servicegraph-dependency-diagram-hotspot-edge.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=9ed90d8fc1db66a5f76a0594642211e7" alt="The image is a diagram showing a &#x22;ServiceGraph&#x22; that maps service dependencies in real time from traces, depicting connections between a client and services A, B, C, and D, highlighting specific issues like &#x22;Hotspot&#x22; and &#x22;Unexpected edge.&#x22;" width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/servicegraph-dependency-diagram-hotspot-edge.jpg" />
</Frame>

Configuration example: route traces through `servicegraph` and expose dependency metrics to Prometheus:

```yaml theme={null}
receivers:
  otlp:
    protocols:
      grpc: {}
      http: {}

exporters:
  prometheus:
    endpoint: 0.0.0.0:8889

connectors:
  servicegraph: {}

service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [servicegraph]
    metrics:
      receivers: [servicegraph]
      exporters: [prometheus]
```

What it produces:

* Metrics showing edges and counts between services.
* Can highlight hotspots and unexpected edges for dependency analysis.

***

## Routing connector (OTTL-based routing)

The Routing connector evaluates OTTL (OpenTelemetry Transformation Language) expressions to dispatch telemetry to different pipelines. Use cases include environment isolation, tenant routing, error pipelines, and fan-out.

Key options:

* `default_pipelines` — where to send unmatched items.
* `match_once` — stop after first match (reduce duplication).
* `error_mode` — how to handle OTTL evaluation errors.

Example: route traces to `traces/prod` if resource has `env=prod`, route error spans (status >= 400) to `traces/errors`, and use a default pipeline for others:

```yaml theme={null}
connectors:
  routing:
    default_pipelines: [traces/default]
    error_mode: ignore
    match_once: true
    table:
      - context: resource
        statement: 'route() where resource.attributes["env"] == "prod"'
        pipelines: [traces/prod]
      - context: span
        statement: 'route() where attributes["http.status_code"] >= 400'
        pipelines: [traces/errors]

service:
  pipelines:
    traces/in:
      receivers: [otlp]
      exporters: [routing]
    traces/prod:
      receivers: [routing]
      exporters: [otlp/prod]
    traces/errors:
      receivers: [routing]
      exporters: [otlp/errors]
    traces/default:
      receivers: [routing]
      exporters: [otlp/default]
```

Example: routing logs from a single `filelog` receiver that contains multiple environments:

```yaml theme={null}
receivers:
  filelog:
    include: ["/var/log/app/*.log"]

exporters:
  otlp/prod:
    endpoint: prod-obsv:4317
  otlp/dev:
    endpoint: dev-obsv:4317

connectors:
  routing/env:
    default_pipelines: [logs/default]
    table:
      - statement: 'attributes["deployment.environment"] == "production"'
        pipelines: [logs/prod]
      - statement: 'attributes["deployment.environment"] == "staging"'
        pipelines: [logs/dev]

service:
  pipelines:
    logs:
      receivers: [filelog]
      exporters: [routing/env]
    logs/prod:
      receivers: [routing/env]
      exporters: [otlp/prod]
    logs/dev:
      receivers: [routing/env]
      exporters: [otlp/dev]
    logs/default:
      receivers: [routing/env]
      exporters: [otlp/dev] # fallback exporter example
```

Routing tips:

* Use `match_once` to avoid duplicates when you only want one destination.
* Use `default_pipelines` to ensure unmatched telemetry still gets processed.
* Test rules with a small dataset to avoid misrouting production telemetry.

***

## Forward connector

The Forward connector is a lightweight bridge that forwards telemetry between pipelines without transformation. It’s useful for merging sources, splitting for multiple downstream destinations, or creating parallel processing branches.

Example: merge logs from two receivers into a single merged logs pipeline, and branch traces into sampled vs all:

```yaml theme={null}
connectors:
  forward: {}

service:
  pipelines:
    logs/blue:
      receivers: [foo/blue]
      processors: [attributes/blue]
      exporters: [forward]
    logs/green:
      receivers: [foo/green]
      processors: [attributes/green]
      exporters: [forward]
    logs/merged:
      receivers: [forward]
      processors: [batch]
      exporters: [otlp]

    traces:
      receivers: [otlp]
      processors: [resourcedetection]
      exporters: [forward]
    traces/sampled:
      receivers: [forward]
      processors: [tail_sampling]
      exporters: [otlp/hot]
    traces/all:
      receivers: [forward]
      exporters: [otlp/cold]
```

When to use forward:

* When you need to combine multiple inputs into one pipeline.
* When you need to create parallel downstream processing (fan-out).

***

## Sum connector

The Sum connector aggregates numeric attributes from spans into time-series sums, optionally grouping by attributes (labels). Useful for business KPIs like revenue, order totals, or counters derived from attributes.

Example: sum order totals and discounts from span attributes, grouped by `promo.code`:

```yaml theme={null}
connectors:
  sum/totals:
    spans:
      purchase.order.total:
        source_attribute: order.total
        conditions:
          - 'attributes["order.total"] != null'
        attributes:
          - key: promo.code
            default_value: none
  sum/discounts:
    spans:
      purchase.discount.total:
        source_attribute: discount.total
        conditions:
          - 'attributes["discount.total"] != null'
        attributes:
          - key: promo.code
            default_value: none
```

Result:

* Time-series `purchase.order.total` and `purchase.discount.total` containing sums of numeric attributes.
* Labels from `promo.code` let you split KPIs by campaign or promotion.

***

## Exceptions connector

The Exceptions connector extracts exception information found in spans and converts that data into logs or log-like telemetry including trace/span IDs for correlation. This is valuable for building error-focused pipelines and alerting.

Example: send traces through `exceptions` to produce logs consumed by a logs pipeline:

```yaml theme={null}
connectors:
  exceptions: {}

service:
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [exceptions, otlp]
    logs:
      receivers: [exceptions]
      processors: [batch]
      exporters: [otlp]
```

What to expect:

* The connector emits structured logs for exceptions that include trace and span IDs.
* Use these logs for alerting, storage in a log backend, or further enrichment.

***

Wrap-up

Connectors let you transform, route, and enrich telemetry inside the Collector without touching application code. They help you:

* Produce SRE metrics and SLIs from traces (spanmetrics, count, sum).
* Build dependency/topology metrics (servicegraph).
* Route and isolate telemetry (routing, forward).
* Extract errors and exceptions for dedicated pipelines (exceptions).

Start small, validate outputs in a staging environment, and monitor for duplicate telemetry or overload when enabling multiple connectors that might fan out signals.

<Callout icon="warning" color="#FF6B6B">
  Be careful with fan-out and overlapping rules. Multiple connectors or routing rules can cause duplicated metrics/logs if match conditions overlap. Test configurations and use `match_once` when appropriate.
</Callout>

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/PzOnM7CVSD5medE3/images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/wrap-up-telemetry-metrics-performance-points.jpg?fit=max&auto=format&n=PzOnM7CVSD5medE3&q=85&s=d593b17c1f37f3e9e16c99e18527a7d5" alt="The image is a slide labeled &#x22;Wrap-up&#x22; that outlines four key points related to telemetry, metrics, and performance. Each point has a number and highlights functions like connectors, common metrics, and strategic guidelines." width="1920" height="1080" data-path="images/Prep-Course-OpenTelemetry-Certified-Associate-OTCA-Certification/OTel-Collector-Core-Components/OTel-Col-Connectors/wrap-up-telemetry-metrics-performance-points.jpg" />
</Frame>

Links and references

* OpenTelemetry Collector: [https://opentelemetry.io/docs/collector/](https://opentelemetry.io/docs/collector/)
* OTTL (OpenTelemetry Transformation Language): [https://opentelemetry.io/docs/collector/transformations/](https://opentelemetry.io/docs/collector/transformations/) (refer to your Collector distribution docs for exact syntax)
* Collector Connectors (see your Collector distribution / contrib docs for supported connector names and options)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/prep-course-opentelemetry-certified-associate-certification-otca/module/f6507634-836f-4fe9-b29d-047d84bfcce7/lesson/ddb4f7cf-8fdb-46e7-b492-7fdecee52d52" />
</CardGroup>
