Skip to content

[pkg/ottl] add a function to remove an element from a Slice/Array #43098

@FranPavelic-SB

Description

@FranPavelic-SB

Component(s)

pkg/ottl

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

I'd like there be the ability to also remove elements from slices/arrays, as the inverse of append

Describe the solution you'd like

  transform/test_list_removal:
    error_mode: ignore
    log_statements:
      - conditions:
          - ContainsValue(log.attributes["tags"], "unparsed")
        statements:
          - append(log.attributes["tags"], "parsed")
          - delete(log.attributes["tags"], "unparsed")

Perhaps this is not the most ideal solution to the problem, but I am currently investigating a replacement for a mass log-processing solution and this is a feature we have heavily relied in our rulesets, to handle bits of processing.

Describe alternatives you've considered

I've not been able to infer a solution from the currently available OTTL functions. Perhaps something involving flatten and delete_key, but coming back from flatten is not the clearest either.

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions