fluent-plugin-record-modifier
fluent-plugin-record-modifier copied to clipboard
Whitelist nested json
Hi!
Is there any way to whitelist nested keys from a json string? Currently whitelisting top level keys works great but I can not find a way to whitelist nested keys.
Thanks in advance
Currently, no way.
Writing such routine in ${...}
is one way like this: https://groups.google.com/d/msg/fluentd/uh0Vb_sOFz4/WSZRHGXcAgAJ
Another way is adding whitelist_for
like parameter to specify field for whitelist_keys
I found a solution for myself in this form:
<filter k8s.events>
@type record_modifier
@id filter_events
<record>
object.count ${record["object"]["count"]}
object.firstTimestamp ${record["object"]["firstTimestamp"]}
object.involvedObject.kind ${record["object"]["involvedObject"]["kind"]}
object.involvedObject.name ${record["object"]["involvedObject"]["name"]}
object.involvedObject.namespace ${record["object"]["involvedObject"]["namespace"]}
object.lastTimestamp ${record["object"]["lastTimestamp"]}
object.message ${record["object"]["message"]}
object.reason ${record["object"]["reason"]}
object.source.component ${record["object"]["source"]["component"]}
object.source.host ${record["object"]["source"]["host"]}
object.type ${record["object"]["type"]}
</record>
whitelist_keys ""
# The commented block below does not work!
#whitelist_keys [
# "$.object.count",
# "$.object.firstTimestamp",
# "$.object.involvedObject.kind",
# "$.object.involvedObject.name",
# "$.object.involvedObject.namespace",
# "$.object.lastTimestamp",
# "$.object.message",
# "$.object.reason",
# "$.object.source.component",
# "$.object.source.host",
# "$.object.type"
# ]
</filter>
Since now records from the block record are automatically added to whitelist_keys, you do not need to re-specify them.
Hope this helps someone