# Signal to Metrics

### Description

This connector generates custom metrics from logs, metrics, and traces using OTTL expressions.

### Use

Use this connector to:

* Count log events as metrics for monitoring error rates or request frequencies
* Generate latency histograms from trace spans
* Derive new metrics from existing metric datapoints
* Build custom service level indicators from raw telemetry

### Supported Types

| Metrics | Logs | Traces |
| ------- | ---- | ------ |
| ✓       | ✓    | ✓      |

All input types produce metrics as output.

### Configuration

| Field              | Description                                                                                    |
| ------------------ | ---------------------------------------------------------------------------------------------- |
| Telemetry Types    | Select which signal types to process: Logs, Metrics, or Traces. At least one must be selected. |
| Metric Definitions | One or more metrics to generate. See metric definition fields below.                           |

#### Metric Definition

| Field               | Description                                                                                                                    |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| Name                | The metric name (e.g., `http.request.count`).                                                                                  |
| Description         | Description of the metric.                                                                                                     |
| Unit                | Metric unit (e.g., `ms`, `bytes`, `logs`).                                                                                     |
| Type                | `Sum`, `Gauge`, `Histogram`, or `Exponential Histogram`.                                                                       |
| Value Expression    | [OTTL expression ](#ottl-expressions)that returns the metric value.                                                            |
| Condition           | OTTL condition to filter which signals generate this metric.                                                                   |
| Buckets             | Bucket boundaries (Histogram only). Default: `[2, 4, 6, 8, 10, 50, 100, 200, 400, 800, 1000, 1400, 2000, 5000, 10000, 15000]`. |
| Max Size            | Max bucket count (Exponential Histogram only). Default: `160`.                                                                 |
| Attributes          | Attributes to include in the output metric.                                                                                    |
| Resource Attributes | Resource attributes to include in the output metric.                                                                           |

#### Metric Types

| Type                  | Description                                                                                                                                                             |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Sum                   | Aggregates numeric values. Use for counters and cumulative metrics.                                                                                                     |
| Gauge                 | Records the last observed value. Use for current state metrics.                                                                                                         |
| Histogram             | Distributes values across explicit buckets. Optionally configure `Buckets` (default: `[2, 4, 6, 8, 10, 50, 100, 200, 400, 800, 1000, 1400, 2000, 5000, 10000, 15000]`). |
| Exponential Histogram | Uses dynamic bucket sizing. Optionally configure `Max Size` (default: `160`).                                                                                           |

#### Attributes

Specify which attributes from the source signal to include in the output metric. If no attributes are defined, the output metric will have no attributes.

| Field         | Description                                                                                                                                                                                                                                            |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Key           | The attribute key to include.                                                                                                                                                                                                                          |
| Behavior      | `Required` (default): incoming signals missing this attribute are skipped entirely. `Optional`: attribute is included if present on incoming signals, excluded if not. `Has Default`: use default value if attribute is missing from incoming signals. |
| Default Value | Value to use when attribute is missing (only with `Has Default`).                                                                                                                                                                                      |

#### Resource Attributes

Specify which resource attributes to include in the output metric. If no resource attributes are defined, **all** incoming resource attributes are included.

| Field         | Description                                                                                          |
| ------------- | ---------------------------------------------------------------------------------------------------- |
| Key           | The resource attribute key to include.                                                               |
| Behavior      | `Optional` (default) or `Has Default`. Same behavior as attributes, but `Required` is not available. |
| Default Value | Value to use when attribute is missing (only with `Has Default`).                                    |

#### Conditions

Filter which signals generate metrics using OTTL conditions.

Example conditions:

* `attributes["http.status_code"] >= 400` — only error responses
* `severity_number >= SEVERITY_NUMBER_ERROR` — only error logs
* `name == "HTTP GET"` — specific span names

#### OTTL Expressions

The connector supports [OTTL functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/ottlfuncs/README.md) for extracting values.

Common expressions:

* `1` — literal value for counting
* `Int(attributes["response_time"])` — extract integer attribute
* `Double(attributes["duration_ms"])` — extract float attribute

For spans, `AdjustedCount()` calculates accurate counts when sampling is enabled:

```
Int(AdjustedCount())
```

### Example Configuration(s)

#### Count Log Records by Severity

Count all log records, grouped by severity level.

* Signal Type: `logs`
* Name: `log.record.count`
* Type: `Sum`
* Value Expression: `1`
* Attributes: Key `severity`, Behavior `Optional`

<figure><img src="/files/MVwagT1rw97Fe9Wlyrd9" alt=""><figcaption></figcaption></figure>

#### HTTP Request Duration Histogram

Generate a latency histogram from HTTP server spans.

* Signal Type: `spans`
* Name: `http.server.duration`
* Unit: `ms`
* Type: `Histogram`
* Value Expression: `Double(attributes["http.server.request.duration"])`
* Condition: `kind == SPAN_KIND_SERVER`
* Buckets: `[5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000]`
* Attributes: Key `http.route`, Behavior `Optional`; Key `http.method`, Behavior `Required`

<figure><img src="/files/LHgG5zmR8QzaTOXGX6qN" alt=""><figcaption></figcaption></figure>

#### Error Count by Service

Count error logs grouped by service name.

* Signal Type: `logs`
* Name: `error.count`
* Type: `Sum`
* Value Expression: `1`
* Condition: `severity_number >= SEVERITY_NUMBER_ERROR`
* Resource Attributes: Key `service.name`, Behavior `Optional`

<figure><img src="/files/H3GXO467Ti0WltoVTq7h" alt=""><figcaption></figcaption></figure>

#### Span Count with Sampling Adjustment

Accurately count spans when sampling is enabled.

* Signal Type: `spans`
* Name: `span.count`
* Type: `Sum`
* Value: `Int(AdjustedCount())`

<figure><img src="/files/jTJFjKJSL8UbxTNuX69k" alt=""><figcaption></figcaption></figure>

### Technical Notes

The connector automatically adds `signaltometrics.service.instance.id` to every output metric for single-writer compliance.

The connector does not perform time-based aggregation. Metrics are aggregated per batch only.

### Related Resources

* [OTTL Syntax Reference](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/README.md)
* [OTTL Functions](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/ottlfuncs/README.md)
* [OTEL Signal to Metrics Documentation](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/connector/signaltometricsconnector/README.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bindplane.com/integrations/connectors/signal-to-metrics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
