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

Missing docs: Best practice for nested keys in record_transformer with high performance #327

Open
bensussman opened this issue Jun 7, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@bensussman
Copy link

bensussman commented Jun 7, 2021

The only example in the record_transformer docs of a "nested key" is here: https://docs.fluentd.org/filter/record_transformer#enable_ruby and here: https://docs.fluentd.org/filter/record_transformer#use-dig-method-for-nested-field

However, these docs also state:

By historical reason, enable_ruby true is too slow. If you need this option, consider record_modifier filter instead. See also Need more performance? section.

Both the the aforementioned examples require enable_ruby. There are no examples of accessing a nested key on a log without using enable_ruby. Is there no way to do nested key access without using enable_ruby and paying a performance cost? It would be ideal if something like:

<filter /^kubernetes.var.log.containers.container-prefix.+_namespacename_.*/>
  @type record_transformer
  <record>
    label1 ${record.dig("kubernetes", "labels", "label1")}
  </record>
</filter>

I understand that enable_ruby is powerful because it allows arbitrary ruby execution, but a simple k1.k2.k3 (with .dig() behavior to handle nulls) would be hugely useful, and could be implemented without the performance hit of arbitrary Ruby.

If this IS indeed possible, the docs should be updated to include an example of this.

@kenhys
Copy link
Contributor

kenhys commented Jun 8, 2021

FYI: I didn't measure actual performance, but the above example can be replaced by record_modifier plugin.

<filter kubernetes>
  @type record_modifier
  <record>
    label1 ${record.dig("kubernetes", "labels", "label1")}
  </record>
</filter>

@kenhys kenhys added the enhancement New feature or request label Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants