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

[pkg/ottl] Converter: MarshalKeyValue #35334

Closed
kuiperda opened this issue Sep 20, 2024 · 7 comments
Closed

[pkg/ottl] Converter: MarshalKeyValue #35334

kuiperda opened this issue Sep 20, 2024 · 7 comments
Labels
enhancement New feature or request pkg/ottl

Comments

@kuiperda
Copy link
Contributor

kuiperda commented Sep 20, 2024

Component(s)

pkg/ottl

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

Problem: Sending Windows Event Logs to QRadar

The recommended approach is to turn the event into key value pairs to put into the syslog rfc3164 message that QRadar expects and will automatically parse.

The current solution for this involves a long list of set and concat funcs to manipulate the parsed record into Key Value format.

Describe the solution you'd like

A simple MarshalKeyValue OTTL converter would take a pcommon.Map and convert it to a string of key value pairs with format k=v k2=v2...

It would be an inverse to the existing ParseKeyValue func. For detailed examples of behavior, see ParseKeyValue tests.

Note: There is some loss in the Parse func, i.e. trimming whitespace, removing wrapping ' and ", and escaping ".
Marshal would persist this loss so composing the funcs would not be an exact inversion.

I would advocate for customizable delimiters with default being = and (space).

Marshal would handle collisions with delimiters in the keys and values by wrapping the k/v in " after escaping any unescaped "

For nested maps and arrays, this simple case could automatically flatten them to the top level. But we may need to decide on a representation for nested maps and arrays and potentially allow customization of those symbols and delimiters as well. The other key consideration here is that Parse does not expect its input to be nested.

Example

MarshalKeyValue(target, Optional[delimiter], Optional[pair_delimiter])

Simple example usage (Initially added as a processor in the Bindplane Agent)

Describe alternatives you've considered

Adding a processor that handles Key Value marshaling. An initial approach to this has already been added in the Bindplane Agent.

Additional context

No response

@kuiperda kuiperda added enhancement New feature or request needs triage New item requiring triage labels Sep 20, 2024
Copy link
Contributor

Pinging code owners:

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

@djaglowski
Copy link
Member

I think key/value format is simple enough that providing a marshaler makes sense. Handling of nested elements can just be a documented caveat that they are rendered as strings. Users can always use the dedicated Flatten function before marshaling if they like that output better.

@odubajDT
Copy link
Contributor

Hello, I would like to look at this issue!

@kuiperda
Copy link
Contributor Author

@odubajDT I am working on an implementation for this already. This issue is intended to gain consensus around a standard.

@kuiperda
Copy link
Contributor Author

Initial implementation added in #35409

@crobert-1
Copy link
Member

Removing needs triage based on response from project maintainer.

@crobert-1 crobert-1 removed the needs triage New item requiring triage label Sep 25, 2024
djaglowski pushed a commit that referenced this issue Oct 1, 2024
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Implements ToKeyValueString OTTL Converter. 

**Link to tracking Issue:** #35334

**Testing:** Added unit tests and e2e

**Documentation:** Added
@kuiperda
Copy link
Contributor Author

kuiperda commented Oct 2, 2024

Completed with #35409

@kuiperda kuiperda closed this as completed Oct 2, 2024
jriguera pushed a commit to springernature/opentelemetry-collector-contrib that referenced this issue Oct 4, 2024
**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->

Implements ToKeyValueString OTTL Converter. 

**Link to tracking Issue:** open-telemetry#35334

**Testing:** Added unit tests and e2e

**Documentation:** Added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pkg/ottl
Projects
None yet
Development

No branches or pull requests

4 participants