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

OTTL: Allow copying attributes with a regex #23444

Closed
gouthamve opened this issue Jun 19, 2023 · 7 comments
Closed

OTTL: Allow copying attributes with a regex #23444

gouthamve opened this issue Jun 19, 2023 · 7 comments
Labels
closed as inactive enhancement New feature or request help wanted Extra attention is needed pkg/ottl priority:p2 Medium processor/transform Transform processor Stale

Comments

@gouthamve
Copy link
Member

Component(s)

pkg/ottl, processor/transform

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

A common usecase in Prometheus is to copy all resource attributes matching a prefix / regex into metric attributes.

Right now its not possible and users are asking for workaround features in the exporter itself: #22914

The usecase in the above issue is that they'd like to copy all the resource attributes withk8s.* regex into metric attributes. And right now they're doing the following:

transform:
  metric_statements:
    - context: datapoint
      statements:
        - set(attributes["k8s_replicaset_name"], resource.attributes["k8s.replicaset.name"])
        - set(attributes["k8s_deployment_name"], resource.attributes["k8s.deployment.name"])
        - set(attributes["k8s_statefulset_name"], resource.attributes["k8s.statefulset.name"])
        - set(attributes["k8s_hpa_name"], resource.attributes["k8s.hpa.name"])
        - set(attributes["k8s_volume_name"], resource.attributes["k8s.volume.name"])
        - set(attributes["k8s_job_name"], resource.attributes["k8s.job.name"])
        ....

This is not scalable as new attributes that are added will be missed.

Describe the solution you'd like

Something like: copy_keys(target, source, regex)

transform:
  metric_statements:
    - context: datapoint
      statements:
        - copy_keys(attributes, resource.attributes, "k8s.*")

Describe alternatives you've considered

No response

Additional context

No response

@gouthamve gouthamve added enhancement New feature or request needs triage New item requiring triage labels Jun 19, 2023
@github-actions github-actions bot added pkg/ottl processor/transform Transform processor labels Jun 19, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@TylerHelmuth
Copy link
Member

We have had similar requests before (#14946) and it continues to be a valuable function to add. @gouthamve is this something you want to work on?

@TylerHelmuth TylerHelmuth added priority:p2 Medium and removed needs triage New item requiring triage labels Jun 20, 2023
@TylerHelmuth
Copy link
Member

I wonder if merge_maps can be used somehow.

@jmichalek132
Copy link
Contributor

I wonder if merge_maps can be used somehow.

Hi, I wrote the referenced issue, that wouldn't work on our use case, since we want to keep the full set of resource attributes on target_info metrics and copy over their subset on the actual metric itself. To be able to use merge_maps we would need to remove items from resource attributes which would remove them from the target_info metric.

@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 Aug 21, 2023
@gouthamve gouthamve removed the Stale label Aug 21, 2023
@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed good first issue Good for newcomers Contribfest labels Oct 11, 2023
@TylerHelmuth TylerHelmuth removed help wanted Extra attention is needed good first issue Good for newcomers labels Oct 21, 2023
@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed and removed Contribfest labels Nov 8, 2023
Copy link
Contributor

github-actions bot commented Jan 8, 2024

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 8, 2024
Copy link
Contributor

github-actions bot commented Mar 8, 2024

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 Mar 8, 2024
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 pkg/ottl priority:p2 Medium processor/transform Transform processor Stale
Projects
None yet
Development

No branches or pull requests

3 participants