|
| 1 | +# Signal to metrics connector |
| 2 | + |
| 3 | +Signal to metrics connector produces metrics from all signal types (traces, |
| 4 | +logs, or metrics). |
| 5 | + |
| 6 | +<!-- status autogenerated section --> |
| 7 | +| Status | | |
| 8 | +| ------------- |-----------| |
| 9 | +| Distributions | [] | |
| 10 | +| Issues | [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Aconnector%2Fsignaltometrics) [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Aconnector%2Fsignaltometrics) | |
| 11 | +| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@ChrsMark](https://www.github.com/ChrsMark), [@lahsivjar](https://www.github.com/lahsivjar) | |
| 12 | + |
| 13 | +[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development |
| 14 | + |
| 15 | +## Supported Pipeline Types |
| 16 | + |
| 17 | +| [Exporter Pipeline Type] | [Receiver Pipeline Type] | [Stability Level] | |
| 18 | +| ------------------------ | ------------------------ | ----------------- | |
| 19 | +| traces | metrics | [development] | |
| 20 | +| logs | metrics | [development] | |
| 21 | +| metrics | metrics | [development] | |
| 22 | + |
| 23 | +[Exporter Pipeline Type]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md#exporter-pipeline-type |
| 24 | +[Receiver Pipeline Type]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/connector/README.md#receiver-pipeline-type |
| 25 | +[Stability Level]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#stability-levels |
| 26 | +<!-- end autogenerated section --> |
| 27 | + |
| 28 | +## Configuration |
| 29 | + |
| 30 | +The component can produce metrics from spans, datapoints (for metrics), and logs. |
| 31 | +At least one of the metrics for one signal type MUST be specified correctly for |
| 32 | +the component to work. |
| 33 | + |
| 34 | +All signal types can be configured to produce metrics with the same configuration |
| 35 | +structure. For example, the below configuration will produce delta temporality counters |
| 36 | +for counting number of events for each of the configured signals: |
| 37 | + |
| 38 | +```yaml |
| 39 | +signaltometrics: |
| 40 | + spans: |
| 41 | + - name: span.count |
| 42 | + description: Count of spans |
| 43 | + sum: |
| 44 | + value: Int(AbsoluteCount()) # Count of total spans represented by each span |
| 45 | + datapoints: |
| 46 | + - name: datapoint.count |
| 47 | + description: Count of datapoints |
| 48 | + sum: |
| 49 | + value: "1" # increment by 1 for each datapoint |
| 50 | + logs: |
| 51 | + - name: logrecord.count |
| 52 | + description: Count of log records |
| 53 | + sum: |
| 54 | + value: "1" # increment by 1 for each log record |
| 55 | +``` |
| 56 | +
|
| 57 | +### Metrics types |
| 58 | +
|
| 59 | +`signaltometrics` produces a variety of metric types by utilizing [OTTL](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/README.md) |
| 60 | +to extract the relevant data for a metric type from the incoming data. The |
| 61 | +component can produce the following metric types for each signal types: |
| 62 | + |
| 63 | +- [Sum](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#sums) |
| 64 | +- [Histogram](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#histogram) |
| 65 | +- [Exponential Histogram](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#exponentialhistogram) |
| 66 | + |
| 67 | +The component does NOT perform any stateful or time based aggregations. The metric |
| 68 | +types are aggregated for the payload sent in each `Consume*` call. The final metric |
| 69 | +is then sent forward in the pipeline. |
| 70 | + |
| 71 | +#### Sum |
| 72 | + |
| 73 | +Sum metrics have the following configurations: |
| 74 | + |
| 75 | +```yaml |
| 76 | +sum: |
| 77 | + value: <ottl_value_expression> |
| 78 | +``` |
| 79 | + |
| 80 | +- [**Required**] `value` represents an OTTL expression to extract a value from the |
| 81 | + incoming data. Only OTTL expressions that return a value are accepted. The |
| 82 | + returned value determines the value type of the `sum` metric (`int` or `double`). |
| 83 | + [OTTL converters](https://pkg.go.dev/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs#readme-converters) |
| 84 | + can be used to transform the data. |
| 85 | + |
| 86 | +#### Histogram |
| 87 | + |
| 88 | +Histogram metrics have the following configurations: |
| 89 | + |
| 90 | +```yaml |
| 91 | +histogram: |
| 92 | + buckets: []float64 |
| 93 | + count: <ottl_value_expression> |
| 94 | + value: <ottl_value_expression> |
| 95 | +``` |
| 96 | + |
| 97 | +- [**Optional**] `buckets` represents the buckets to be used for the histogram. |
| 98 | + If no buckets are configured then it defaults to: |
| 99 | + |
| 100 | + ```go |
| 101 | + []float64{2, 4, 6, 8, 10, 50, 100, 200, 400, 800, 1000, 1400, 2000, 5000, 10_000, 15_000} |
| 102 | + ``` |
| 103 | + |
| 104 | +- [**Optional**] `count` represents an OTTL expression to extract the count to be |
| 105 | + recorded in the histogram from the incoming data. If no expression is provided |
| 106 | + then it defaults to the count of the signal i.e. [adjusted count](https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling-experimental/#adjusted-count) |
| 107 | + for spans and count for others. [OTTL converters](https://pkg.go.dev/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs#readme-converters) |
| 108 | + can be used to transform the data. |
| 109 | +- [**Required**] `value` represents an OTTL expression to extract the value to be |
| 110 | + recorded in the histogram from the incoming data. [OTTL converters](https://pkg.go.dev/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs#readme-converters) |
| 111 | + can be used to transform the data. |
| 112 | + |
| 113 | +#### Exponential Histogram |
| 114 | + |
| 115 | +Exponential histogram metrics have the following configurations: |
| 116 | + |
| 117 | +```yaml |
| 118 | +exponential_histogram: |
| 119 | + max_size: <int64> |
| 120 | + count: <ottl_value_expression> |
| 121 | + value: <ottl_value_expression> |
| 122 | +``` |
| 123 | + |
| 124 | +- [**Optional**] `max_size` represents the maximum number of buckets per positive |
| 125 | + or negative number range. Defaults to `160`. |
| 126 | +- [**Optional**] `count` represents an OTTL expression to extract the count to be |
| 127 | + recorded in the exponential histogram from the incoming data. If no expression |
| 128 | + is provided then it defaults to the count of the signal i.e. [adjusted count](https://opentelemetry.io/docs/specs/otel/trace/tracestate-probability-sampling-experimental/#adjusted-count) |
| 129 | + for spans and count for others. |
| 130 | + [OTTL converters](https://pkg.go.dev/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs#readme-converters) can be used to transform the data. |
| 131 | +- [**Required**] `value` represents an OTTL expression to extract the value to be recorded |
| 132 | + in the exponential histogram from the incoming data. |
| 133 | + [OTTL converters](https://pkg.go.dev/github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs#readme-converters) can be used to transform the data. |
| 134 | + |
| 135 | +### Attributes |
| 136 | + |
| 137 | +The component can produce metrics categorized by the attributes (span attributes |
| 138 | +for traces, datapoint attributes for datapoints, or log record attributes for logs) |
| 139 | +from the incoming data by configuring `attributes` for the configured metrics. |
| 140 | + |
| 141 | +If no `attributes` are configured then the metrics are produced without any attributes. |
| 142 | + |
| 143 | +```yaml |
| 144 | +attributes: |
| 145 | + - key: datapoint.foo |
| 146 | + - key: datapoint.bar |
| 147 | + default_value: bar |
| 148 | +``` |
| 149 | + |
| 150 | +If attributes are specified then a separate metric will be generated for each unique |
| 151 | +set of attribute values. Optionally, a `default_value` can be used to always include |
| 152 | +the attribute with the value of the attribute defaulting to the value specified in |
| 153 | +`default_value` if the incoming data is missing that attribute. |
| 154 | + |
| 155 | +### Conditions |
| 156 | + |
| 157 | +Conditions are an optional list of OTTL conditions that are evaluated on the incoming |
| 158 | +data and are ORed together. For example: |
| 159 | + |
| 160 | +```yaml |
| 161 | +signaltometrics: |
| 162 | + datapoints: |
| 163 | + - name: datapoint.bar.sum |
| 164 | + description: Count total number of datapoints as per datapoint.bar attribute |
| 165 | + conditions: |
| 166 | + - resource.attributes["foo"] != nil |
| 167 | + - resource.attributes["bar"] != nil |
| 168 | + sum: |
| 169 | + value: "1" |
| 170 | +``` |
| 171 | + |
| 172 | +The above configuration will produce sum metrics from datapoints with either `foo` |
| 173 | +OR `bar` resource attribute defined. |
| 174 | + |
| 175 | +Conditions can also be ANDed together, for example: |
| 176 | + |
| 177 | +```yaml |
| 178 | +signaltometrics: |
| 179 | + datapoints: |
| 180 | + - name: gauge.to.exphistogram |
| 181 | + conditions: |
| 182 | + - metric.type == 1 AND resource.attributes["resource.foo"] != nil |
| 183 | + exponential_histogram: |
| 184 | + count: "1" # 1 count for each datapoint |
| 185 | + value: Double(value_int) + value_double # handle both int and double |
| 186 | +``` |
| 187 | + |
| 188 | +The above configuration produces exponential histogram from gauge metrics with resource |
| 189 | +attributes `resource.foo` set. |
| 190 | + |
| 191 | +### Customizing resource attributes |
| 192 | + |
| 193 | +The component allows customizing the resource attributes for the produced metrics |
| 194 | +by specifying a list of attributes that should be included in the final metrics. |
| 195 | +If no attributes are specified for `include_resource_attributes` then no filtering |
| 196 | +is performed i.e. all resource attributes of the incoming data is considered. |
| 197 | + |
| 198 | +```yaml |
| 199 | +include_resource_attributes: |
| 200 | + - key: resource.foo # Include resource.foo attribute if present |
| 201 | + - key: resource.bar # Always include resource.bar attribute, default to bar |
| 202 | + default_value: bar |
| 203 | +``` |
| 204 | + |
| 205 | +With the above configuration the produced metrics would only have the couple of |
| 206 | +resource attributes specified in the list: |
| 207 | + |
| 208 | +- `resource.foo` will be present for the produced metrics if the incoming data also |
| 209 | + has the attribute defined. |
| 210 | +- `resource.bar` will always be present because of the `default_value`. If the incoming |
| 211 | + data does not have a resource attribute with name `resource.bar` then the configured |
| 212 | + `default_value` of `bar` will be used. |
| 213 | + |
| 214 | +### Single writer |
| 215 | + |
| 216 | +Metrics data streams MUST obey [single-writer](https://opentelemetry.io/docs/specs/otel/metrics/data-model/#single-writer) |
| 217 | +principle. However, since `signaltometrics` component produces metrics from all signal |
| 218 | +types and also allows customizing the resource attributes, there is a possibility |
| 219 | +of violating the single-writer principle. To keep the single-writer principle intact, |
| 220 | +the component adds collector instance information as resource attributes. The following |
| 221 | +resource attributes are added to each produced metrics: |
| 222 | + |
| 223 | +```yaml |
| 224 | +signaltometrics.service.name: <service_name_of_the_otel_collector> |
| 225 | +signaltometrics.service.namespace: <service_namespace_of_the_otel_collector> |
| 226 | +signaltometrics.service.instance.id: <service_instance_id_of_the_otel_collector> |
| 227 | +``` |
0 commit comments