Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[processor/metricstransform] support value regex matching pattern when renaming label values #25913

Closed
karmingc opened this issue Aug 21, 2023 · 3 comments
Labels
enhancement New feature or request needs triage New item requiring triage processor/metricstransform Metrics Transform processor Stale

Comments

@karmingc
Copy link
Contributor

karmingc commented Aug 21, 2023

Component(s)

processor/metricstransform

Is your feature request related to a problem? Please describe.

Currently, the metricstranform processor support renaming label values such as the following:

# from https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#rename-label-values
# rename the label value slab_reclaimable to sreclaimable, slab_unreclaimable to sunreclaimable
include: system.memory.usage
action: update
operations:
  - action: update_label
    label: state
    value_actions:
      - value: slab_reclaimable
        new_value: sreclaimable
      - value: slab_unreclaimable
        new_value: sunreclaimable

However, there might be situations where we want to use a regex matching pattern instead of a strict one. For example, when dealing with http.status_code, the range goes from 1xx to 5xx so adding these values 1 by 1 is long and can be error-prone.

The goal is to reduce cardinality such as 200, 201, 202... to 2xx to reduce cardinality.

Describe the solution you'd like

Potentially add a value_match_type field under the operations field. But open to suggestion.

Describe alternatives you've considered

We can leverage the transform processor such as:

  transform/metric:
    error_mode: ignore
    metric_statements:
      - context: datapoint
        statements:
          - replace_pattern(attributes["http.status_code"], "\\b1\\d{2}\\b", "1xx")
          - replace_pattern(attributes["http.status_code"], "\\b2\\d{2}\\b", "2xx")
          - replace_pattern(attributes["http.status_code"], "\\b3\\d{2}\\b", "3xx")
          - replace_pattern(attributes["http.status_code"], "\\b4\\d{2}\\b", "4xx")
          - replace_pattern(attributes["http.status_code"], "\\b5\\d{2}\\b", "5xx")

Additional context

No response

@karmingc karmingc added enhancement New feature or request needs triage New item requiring triage labels Aug 21, 2023
@github-actions github-actions bot added the processor/metricstransform Metrics Transform processor label Aug 21, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

  • processor/metricstransform: @dmitryax
  • needs: Github issue template generation code needs this to generate the corresponding labels.

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@crobert-1
Copy link
Member

I believe this is a duplicate of #24366, but please let me know if I've misunderstood

@crobert-1 crobert-1 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New item requiring triage processor/metricstransform Metrics Transform processor Stale
Projects
None yet
Development

No branches or pull requests

2 participants