You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `aggregate_on_attributes` function aggregates all datapoints in the metric based on the supplied attributes. `function` is a case-sensitive string that represents the aggregation function and `attributes` is an optional list of attribute keys to aggregate upon.
378
+
The `aggregate_on_attributes` function aggregates all datapoints in the metric based on the supplied attributes. `function` is a case-sensitive string that represents the aggregation function and `attributes` is an optional list of attribute keys of type string to aggregate upon.
378
379
379
380
`aggregate_on_attributes`function removes all attributes that are present in datapoints except the ones that are specified in the `attributes` parameter. If `attributes` parameter is not set, all attributes are removed from datapoints. Afterwards all datapoints are aggregated depending on the attributes left (none or the ones present in the list).
380
381
382
+
**NOTE:** This function is supported only in `metric` context.
383
+
381
384
The following metric types can be aggregated:
382
385
383
386
- sum
@@ -415,6 +418,50 @@ statements:
415
418
416
419
To aggregate only using a specified set of attributes, you can use `keep_matching_keys`.
The `aggregate_on_attribute_value` function aggregates all datapoints in the metric containing the attribute `attribute` (type string) with one of the values present in the `values` parameter (list of strings) into a single datapoint where the attribute has the value `newValue` (type string). `function` is a case-sensitive string that represents the aggregation function.
426
+
427
+
**NOTE:** This function is supported only in `metric` context.
428
+
429
+
The following metric types can be aggregated:
430
+
431
+
- sum
432
+
- gauge
433
+
- histogram
434
+
- exponential histogram
435
+
436
+
Supported aggregation functions are:
437
+
438
+
- sum
439
+
- max
440
+
- min
441
+
- mean
442
+
- median
443
+
- count
444
+
445
+
**NOTE:** Only the `sum` agregation function is supported for histogram and exponential histogram datatypes.
446
+
447
+
Examples:
448
+
449
+
- `aggregate_on_attribute_value("sum", "attr1", ["val1", "val2"], "new_val") where name == "system.memory.usage"`
450
+
451
+
The `aggregate_on_attribute_value` function can also be used in conjunction with
452
+
[keep_matching_keys](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/ottl/ottlfuncs#keep_matching_keys) or
For example, to remove attribute keys matching a regex and aggregate the metrics on the remaining attributes, you can perform the following statement sequence:
456
+
457
+
```yaml
458
+
statements:
459
+
- delete_matching_keys(attributes, "(?i).*myRegex.*") where name == "system.memory.usage"
460
+
- aggregate_on_attribute_value("sum", "attr1", ["val1", "val2"], "new_val") where name == "system.memory.usage"
461
+
```
462
+
463
+
To aggregate only using a specified set of attributes, you can use `keep_matching_keys`.
464
+
418
465
## Examples
419
466
420
467
### Perform transformation if field does not exist
0 commit comments