我有一个有json记录的文件,想要在将它们发送到流畅的输出之前从json记录中删除一些键。我可以使用'record_transformer Filter Plugin'删除密钥,但它只从json中删除顶级密钥。我如何使用嵌套键。
示例输入:
{
"key1": 1,
"key2": 2,
"key3": {
"nested_key1": 1,
"nested_key2": 1,
"nested_key3": 1,
"nested_key4": {
"double_nested_key1": 1,
"double_nested_key2": 2
}
}
}
输出样本:
{
"key1": 1,
"key2": 2,
"key3": {
"nested_key1": 1,
"nested_key2": 1,
"nested_key4": {
"double_nested_key2": 2
}
}
}
答案 0 :(得分:1)
答案 1 :(得分:0)
https://docs.fluentd.org/v1.0/articles/api-plugin-helper-record_accessor#syntax
<filter fluentd-log.**>
@type record_transformer
remove_keys a, $.b.c, $.b.c.d
</filter>
答案 2 :(得分:-1)
根据this,您可以使用以下内容:
<record>
for_remove ${record["docker"].delete("container_id")}
</record>
remove_keys for_remove
结构如:
"docker": {
"container_id": "c1853368630a300cac78890a8599c77cea23a3fe57961e4080722c74a3ba7430"
},
结果你会得到:
"docker": {},