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

✨ Flatten results of VRL scripts #76

Merged
merged 4 commits into from
Sep 11, 2024
Merged

✨ Flatten results of VRL scripts #76

merged 4 commits into from
Sep 11, 2024

Conversation

linkdd
Copy link
Contributor

@linkdd linkdd commented Sep 11, 2024

Decision Record

In FlowG, a log record is a flat map of string -> string. But a VRL script can return more complex/nested values.

In order to properly serialize the result of a VRL script to the format FlowG expects:

  • Bytes, Regex, Timestamp, Integer, Float and Boolean are translated to UTF-8 strings
  • Null is translated to an empty string
  • Object and Array are flattened

For example, the following script:

.foo = 42
.bar.baz = [1, 2, 3, "a"]
.

Would return the following object (given an empty record as input):

{
  "foo": 42,
  "bar": {
    "baz": [1, 2, 3, "a"]
  }
}

Once flattened and with every value serialized to a string:

{
  "foo": "42",
  "bar.baz.0": "1",
  "bar.baz.1": "2",
  "bar.baz.2": "3",
  "bar.baz.3": "a"
}

Changes

  • ✨ Flatten the result of a VRL script
  • ✅ Add test cases for VRL scripts

License Agreement

  • I guarantee that I have the rights on the code submitted in this PR
  • I accept that this contribution will be released under the terms of the MIT License

@linkdd linkdd added this to the 1.0.0 milestone Sep 11, 2024
@linkdd linkdd self-assigned this Sep 11, 2024
@linkdd linkdd merged commit ab38979 into main Sep 11, 2024
2 checks passed
@linkdd linkdd deleted the vrl-flatten branch September 11, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant