replace - 如何在fluentd中用特定字符串替换键值字符串
问题描述
我是 fluentd 的新手,当键值中出现特定字符串时,我想使用 record_modifier 替换字符串。
例子
1)输入:
{"message":"how are you"}
输出 :
{"message":"who are you"}
当输入具有“how”的键值时,我想用“who”替换该字符串
2)输入:
{"message":"he is a bad boy"}
输出 :
{"message":"he is a good boy"}
当输入键值具有“坏”时,我想用“好”替换该字符串
@type record_modifier #auto_typecast true
enter code here
关键信息表达式 ????? 代替 ?????
提前致谢。
解决方案
您可以在record_transformer中使用gsub
<filter yourTag>
@type record_transformer
enable_ruby
<record>
log ${record["log"].gsub('how', 'who')}
</record>
</filter>
推荐阅读
- c++ - 为什么在这个 C++ 问题中使用 const_iterator 而不仅仅是迭代器?
- visual-studio-code - 我可以为已弃用的组件禁用自动导入和导入建议吗?
- ruby - 从 jekyll-sitemap 插件中获取错误:未定义的方法 `fetch' 为 true:sitemap.xml 中的 TrueClass
- .net - 如果 WPF 类更改,F# 无法加载 FSharp.Core
- php - PHP 警告:array_combine():两个参数应该有相同数量的元素 - CSV 没有正确解析?
- javascript - 如何从 javascript 中读取 mix-manifest.json
- html - CSS/HTML 仅选择一些引导元素
- angular - ngModel 的 ion-radio-group 问题
- dpdk - 每个 NIC 队列一个缓冲池
- excel - Excel VBA自动填充未填充第一行和第一列