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/transform] Add option for aggregating metrics with same metric identity (resolving Identity Conflict) #16325

Closed
adam-kiss-sg opened this issue Nov 16, 2022 · 3 comments
Labels
closed as inactive enhancement New feature or request help wanted Extra attention is needed priority:p2 Medium processor/transform Transform processor Stale

Comments

@adam-kiss-sg
Copy link
Contributor

adam-kiss-sg commented Nov 16, 2022

Component(s)

processor/transform

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

I have metrics produced by spanmetrics processor, which has an attribute for the http status code. I would like to instead have status classes (eg: 2xx, 4xx, 5xx). If i rename the labels of the metrics, it would lead to Identity Conflict

Describe the solution you'd like

I would like to be able to specify how to merge metrics with the same identity after all transformation has run. (eg: sum, mean, min, max).

  transform:
    metrics:
      statements:
        - set(attributes["status_class"], attributes["http.status_code"])
        - replace_match(attributes["status_class"], "2*", "2xx")
        - replace_match(attributes["status_class"], "4*", "4xx")
        - replace_match(attributes["status_class"], "5*", "5xx")
        - keep_keys(attributes, ["net.host.port", "http.method", "http.status_code"])
        - aggregate_same_identity_metrics("sum")

Describe alternatives you've considered

I have looked at metricstransform processor, but i would need to specify all status codes there (eg: from 200 to 299), and also create a group for all of these, eg:

  transform/spanmetrics:                                                                                                 
    metrics:                                                                                                             
      statements:                                                                          
        # workaround to convert http.status_code to string, because metricstransform aggregate_label_values only works with strings
        - set(attributes["http.status_code"], Concat([attributes["http.status_code"]], ""))
  metricstransform/spanmetrics:
    transforms:
      - include: calls_total|latency
        match_type: regexp
        action: update
        operations:
          - action: aggregate_label_values
            label: http.status_code
            aggregated_values: [ 
              "200", "201", "202", "203", "204", "205", "206", "207", "208", "209",
              "210", "211", "212", "213", "214", "215", "216", "217", "218", "219",
              "220", "221", "222", "223", "224", "225", "226", "227", "228", "229",
              "230", "231", "232", "233", "234", "235", "236", "237", "238", "239",
              "240", "241", "242", "243", "244", "245", "246", "247", "248", "249",
              "250", "251", "252", "253", "254", "255", "256", "257", "258", "259",
              "260", "261", "262", "263", "264", "265", "266", "267", "268", "269",
              "270", "271", "272", "273", "274", "275", "276", "277", "278", "279",
              "280", "281", "282", "283", "284", "285", "286", "287", "288", "289",
              "290", "291", "292", "293", "294", "295", "296", "297", "298", "299",
            ]
            new_value: 2xx 
            aggregation_type: sum
          - action: aggregate_label_values
            label: http.status_code
            aggregated_values: [ 
              "400", "401", "402", "403", "404", "405", "406", "407", "408", "409",
              "410", "411", "412", "413", "414", "415", "416", "417", "418", "419",
              "420", "421", "422", "423", "424", "425", "426", "427", "428", "429",
              "430", "431", "432", "433", "434", "435", "436", "437", "438", "439",
              "440", "441", "442", "443", "444", "445", "446", "447", "448", "449",
              "450", "451", "452", "453", "454", "455", "456", "457", "458", "459",
              "460", "461", "462", "463", "464", "465", "466", "467", "468", "469",
              "470", "471", "472", "473", "474", "475", "476", "477", "478", "479",
              "480", "481", "482", "483", "484", "485", "486", "487", "488", "489",
              "490", "491", "492", "493", "494", "495", "496", "497", "498", "499",
            ]
            new_value: 4xx 
            aggregation_type: sum
          - action: aggregate_label_values
            label: http.status_code
            aggregated_values: [ 
              "500", "501", "502", "503", "504", "505", "506", "507", "508", "509",
              "510", "511", "512", "513", "514", "515", "516", "517", "518", "519",
              "520", "521", "522", "523", "524", "525", "526", "527", "528", "529",
              "530", "531", "532", "533", "534", "535", "536", "537", "538", "539",
              "540", "541", "542", "543", "544", "545", "546", "547", "548", "549",
              "550", "551", "552", "553", "554", "555", "556", "557", "558", "559",
              "560", "561", "562", "563", "564", "565", "566", "567", "568", "569",
              "570", "571", "572", "573", "574", "575", "576", "577", "578", "579",
              "580", "581", "582", "583", "584", "585", "586", "587", "588", "589",
              "590", "591", "592", "593", "594", "595", "596", "597", "598", "599",
            ]
            new_value: 5xx 
            aggregation_type: sum

Additional context

I believe this feature could address this issue as well: #16224, but is more flexible then the proposed solution there, as it can be combined with other features of the transform processor:

It would also allow some other use-cases, like:

  • combining metrics
  • easily dropping labels, or using keep_keys without worrying about metric identity
  • using different labels in different envs (dev/prod), without modifying application code
@adam-kiss-sg adam-kiss-sg added enhancement New feature or request needs triage New item requiring triage labels Nov 16, 2022
@github-actions github-actions bot added the processor/transform Transform processor label Nov 16, 2022
@github-actions
Copy link
Contributor

Pinging code owners:

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

@TylerHelmuth TylerHelmuth changed the title Add option for aggregating metrics with same metric identity (resolving Identity Conflict) [processor/transform] Add option for aggregating metrics with same metric identity (resolving Identity Conflict) Nov 16, 2022
@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed priority:p2 Medium and removed needs triage New item requiring triage labels Nov 16, 2022
@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:

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

@github-actions github-actions bot added the Stale label Jan 16, 2023
@github-actions
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed as inactive enhancement New feature or request help wanted Extra attention is needed priority:p2 Medium processor/transform Transform processor Stale
Projects
None yet
Development

No branches or pull requests

2 participants