|
| 1 | +# Sum Connector |
| 2 | +<!-- status autogenerated section --> |
| 3 | +| Status | | |
| 4 | +| ------------- |-----------| |
| 5 | +| Distributions | [] | |
| 6 | +| Issues | [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aconnector%2Fsum) [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aconnector%2Fsum) | |
| 7 | +| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@greatestusername](https://www.github.com/greatestusername), [@shalper2](https://www.github.com/shalper2), [@crobert-1](https://www.github.com/crobert-1) | |
| 8 | + |
| 9 | +[development]: https://github.com/open-telemetry/opentelemetry-collector#development |
| 10 | + |
| 11 | +## Supported Pipeline Types |
| 12 | + |
| 13 | +| [Exporter Pipeline Type] | [Receiver Pipeline Type] | [Stability Level] | |
| 14 | +| ------------------------ | ------------------------ | ----------------- | |
| 15 | +| traces | metrics | [development] | |
| 16 | +| metrics | metrics | [development] | |
| 17 | +| logs | metrics | [development] | |
| 18 | + |
| 19 | +[Exporter Pipeline Type]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md#exporter-pipeline-type |
| 20 | +[Receiver Pipeline Type]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md#receiver-pipeline-type |
| 21 | +[Stability Level]: https://github.com/open-telemetry/opentelemetry-collector#stability-levels |
| 22 | +<!-- end autogenerated section --> |
| 23 | + |
| 24 | +The `sum` connector can be used to sum attribute values from spans, span events, metrics, data points, and log records. |
| 25 | + |
| 26 | +## Configuration |
| 27 | + |
| 28 | +If you are not already familiar with connectors, you may find it helpful to first visit the [Connectors README](https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md). |
| 29 | + |
| 30 | +### Configuration |
| 31 | + |
| 32 | +#### Basic configuration |
| 33 | + |
| 34 | +This configuration will sum numerical values found within the attribute `attribute.with.numerical.value` of any log telemetry routed to the connector. It will then output a metric time series with the name `my.example.metric.name` with those summed values. |
| 35 | + |
| 36 | +```yaml |
| 37 | +receivers: |
| 38 | + foo: |
| 39 | +connectors: |
| 40 | + sum: |
| 41 | + logs: |
| 42 | + my.example.metric.name: |
| 43 | + source_attribute: attribute.with.numerical.value |
| 44 | +exporters: |
| 45 | + bar: |
| 46 | + |
| 47 | +service: |
| 48 | + pipelines: |
| 49 | + metrics/sum: |
| 50 | + receivers: [sum] |
| 51 | + exporters: [bar] |
| 52 | + logs: |
| 53 | + receivers: [foo] |
| 54 | + exporters: [sum] |
| 55 | +``` |
| 56 | +
|
| 57 | +#### Required Settings |
| 58 | +
|
| 59 | +The sum connector has three required configuration settings and numerous optional settings |
| 60 | +
|
| 61 | +- Telemetry type: Nested below the `sum:` connector declaration. Declared as `logs:` in the [Basic Example](#basic-configuration). |
| 62 | + - Can be any of `spans`, `spanevents`, `metrics`, `datapoints`, or `logs`. |
| 63 | +- Metric name: Nested below the telemetry type; this is the metric name the sum connector will output summed values to. Declared as `my.example.metric.name` in the [Basic Example](#basic-configuration) |
| 64 | +- `source_attribute`: A specific attribute to search for within the source telemetry being fed to the connector. This attribute is where the connector will look for numerical values to sum into the output metric value. Declared as `attribute.with.numerical.value` in the [Basic Example](#basic-configuration) |
| 65 | + |
| 66 | +#### Optional Settings |
| 67 | + |
| 68 | +- `conditions`: [OTTL syntax](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/LANGUAGE.md) can be used to provide conditions for processing incoming telemetry. Conditions are ORed together, so if any condition is met the attribute's value will be included in the resulting sum. |
| 69 | +- `attributes`: Declaration of attributes to include. Any of these attributes found will generate a separate sum for each set of unique combination of attribute values and output as its own datapoint in the metric time series. |
| 70 | + - `key`: (required for `attributes`) the attribute name to match against |
| 71 | + - `default_value`: (optional for `attributes`) a default value for the attribute when no matches are found. The `default_value` value can be of type string, integer, or float. |
| 72 | + |
| 73 | +#### Detailed Example Configuration |
| 74 | + |
| 75 | +This example declares that the `sum` connector is going to be ingesting `logs` and creating an output metric named `checkout.total` with numerical values found in the `source_attribute` `total.payment`. |
| 76 | + |
| 77 | +It provides a condition to check that the attribute `total.payment` is not `NULL`. It also checks any incoming log telemetry for values present in the attribute `payment.processor` and creates a datapoint within the metric time series for each unique value. Any logs without values in `payment.processor` will be included in a datapoint with the `default_value` of `unspecified_processor`. |
| 78 | + |
| 79 | +```yaml |
| 80 | +receivers: |
| 81 | + foo: |
| 82 | +connectors: |
| 83 | + sum: |
| 84 | + logs: |
| 85 | + checkout.total: |
| 86 | + source_attribute: total.payment |
| 87 | + conditions: |
| 88 | + - attributes["total.payment"] != "NULL" |
| 89 | + attributes: |
| 90 | + - key: payment.processor |
| 91 | + default_value: unspecified_processor |
| 92 | +exporters: |
| 93 | + bar: |
| 94 | +
|
| 95 | +service: |
| 96 | + pipelines: |
| 97 | + metrics/sum: |
| 98 | + receivers: [sum] |
| 99 | + exporters: [bar] |
| 100 | + logs: |
| 101 | + receivers: [foo] |
| 102 | + exporters: [sum] |
| 103 | +``` |
| 104 | + |
| 105 | +[Connectors README]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md |
0 commit comments