如何使用 Logstash 的 JSON 过滤器插件
How to use the JSON Filter Plugin for Logstash
我已在他们的网站 (https://www.elastic.co/guide/en/logstash/current/plugins-filters-json.html) 上阅读了此文档,但仍在努力了解如何使用此插件。我的目标是获取一个 JSON 文件并删除除分布在 JSON 日志周围的几个特定字段之外的所有内容。 Add_field 过滤器是否只传递添加的字段?如果是这样,我将如何指定要传递的内容?
JSON 过滤器用于在字段中扩展 json。要将 JSON 文件读入 logstash,您可能需要使用 json
codec with a file
input,有点像这样:
file {
path => "/path/to/file"
codec => "json"
}
这会将 json 文件作为一个事件读入 logstash 或
If the data being sent is a JSON array at its root multiple events will be created (one per element).
然后您可以使用 mutate
filter 删除不需要的字段。
mutate {
remove_field => [ "uneeded-field", "my_extraneous_field" ]
}
您也可以考虑使用社区 prune
filter,它可以删除白名单以外的所有内容。
我已在他们的网站 (https://www.elastic.co/guide/en/logstash/current/plugins-filters-json.html) 上阅读了此文档,但仍在努力了解如何使用此插件。我的目标是获取一个 JSON 文件并删除除分布在 JSON 日志周围的几个特定字段之外的所有内容。 Add_field 过滤器是否只传递添加的字段?如果是这样,我将如何指定要传递的内容?
JSON 过滤器用于在字段中扩展 json。要将 JSON 文件读入 logstash,您可能需要使用 json
codec with a file
input,有点像这样:
file {
path => "/path/to/file"
codec => "json"
}
这会将 json 文件作为一个事件读入 logstash 或
If the data being sent is a JSON array at its root multiple events will be created (one per element).
然后您可以使用 mutate
filter 删除不需要的字段。
mutate {
remove_field => [ "uneeded-field", "my_extraneous_field" ]
}
您也可以考虑使用社区 prune
filter,它可以删除白名单以外的所有内容。