- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
Description
We need to provide users with the ability to change a set of attributes emitted by a metrics receiver by applying an automatic re-aggregation of the data points. For example, system.cpu.time is emitted by default with state and cpu attributes. Many users don't need metrics per CPU core, so they would like to get metrics per host and state instead. Currently, they would need to set up an additional metricstransform processor to achieve that. But this can happen inside the metrics builder instead.
Changes to metadata.yaml interface for receiver builders
metrics:
  system.cpu.time:
    enabled: true
    description: Total CPU seconds broken down by different states.
    unit: s
    sum:
      value_type: double
      aggregation: cumulative. # Probably to be renamed to not confuse with attributes_aggregation
      monotonic: true
    attributes_aggregation: sum  # NEW FIELD, name of the field is TBD
    attributes:
      cpu:
        enabled: true  # NEW FIELD
        description: CPU number starting at 0.
      state:
        enabled: true  # NEW FIELD
        description: Breakdown of CPU usage by type.
        enum: [idle, interrupt, nice, softirq, steal, system, user, wait]
This will also allow us to introduce the notion of Optional attributes that are disabled by default. E.g. cpu core is a good candidate for that.
This also requires moving the attributes section from the top level under each metric removing the naming confusion between the name of an attribute key and value field that not be needed anymore. Receiver authors that don't like the additional repetition can use YAML anchors instead.
Additional interface to user configuration
The metrics interface will get additional fields to disable/enable metrics and change the aggregation type. For example:
metrics:
  system.cpu.time:
    attributes_aggregation: [sum|avg|min|max]
    attributes:
      cpu:
        enabled: [true|false]
      state:
        enabled: [true|false]
Action items
-  Move the attributes section under each metric
-  Rename sum.aggregationfield to not confuse it with attributes_aggregation
- Introduce the re-aggregation functionality in the metrics builder