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

It should be possible to set specific paths in Remap variables #6319

Closed
StephenWakely opened this issue Feb 2, 2021 · 0 comments · Fixed by #6353
Closed

It should be possible to set specific paths in Remap variables #6319

StephenWakely opened this issue Feb 2, 2021 · 0 comments · Fixed by #6353
Assignees
Labels
domain: vrl Anything related to the Vector Remap Language type: enhancement A value-adding code change that enhances its existing functionality.

Comments

@StephenWakely
Copy link
Contributor

It would be useful to be able to modify paths within variables, so array indexes and subfields of the variable. Currently Remap just errors if this is attempted.

From discord

It would be useful to do this:

       if length(message_lines) > 1 {
          message_lines[0] = ""
          .log.extra = compact(message_lines, string: true)
        }

But currently we get this error:

error: path-based variable assignment
     ┌─ :65:2365 │           message_lines[0] = ""------------^^^^ assignment to variable path currently unsupported
     │           │
     │           assign to "message_lines" instead
     │
     = see language documentation at: https://vector.dev/docs/reference/vrl/

The only workaround currently is to temporarily move the variable to a path (which would not work for metric events):

.temp = message_lines
.temp[0] = ""
message_lines = .temp
del(.temp)
@StephenWakely StephenWakely added type: enhancement A value-adding code change that enhances its existing functionality. domain: vrl Anything related to the Vector Remap Language labels Feb 2, 2021
@JeanMertz JeanMertz self-assigned this Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain: vrl Anything related to the Vector Remap Language type: enhancement A value-adding code change that enhances its existing functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants