- 文档首页
日志服务
用户指南
数据采集
LogCollector 采集
LogCollector 插件
JSON 提取插件
JSON 提取插件
您可以使用 LogCollector 的 json_extract 插件,指定 JSONPath 表达式从指定 JSON 内容中提取一个或多个值,并将其作为一个新的 JSON 数组添加到日志中。
说明
LogCollector V2.2.5 及后续版本支持该插件。如何查看 LogCollector 版本,请参考2 查看软件版本。 "name": {"first": "Tom", "last": "Anderson"},
"children": ["Sara","Alex","Jack"],
"fav.movie": "Deer Hunter",
{"first": "Dale", "last": "Murphy", "age": 44, "nets": ["ig", "fb", "tw"]},
{"first": "Roger", "last": "Craig", "age": 68, "nets": ["fb", "tw"]},
{"first": "Jane", "last": "Murphy", "age": 47, "nets": ["ig", "tw"]}
- 日志内容如下,其中 request_body 字段的值是 JSON 字符串:
"timestamp": "2023-10-26T10:30:00Z",
"source_ip": "192.168.1.100",
"request_body": "{\"user\": {\"id\": \"usr_123\", \"username\": \"alice\", \"attributes\": {\"roles\": [\"administrator\", \"power_user\"], \"department\": \"engineering\"}}, \"action\": \"update_profile\"}"
- LogCollector 的 json_extract 插件处理器配置:
- 从request_body字段的 JSON 内容中,以 JSONPath 表达式为user.attributes.roles提取值,并将值存储至user_roles字段中。
"field": "request_body",
"json_path": "user.attributes.roles",
"new_field": "user_roles"
"timestamp": "2023-10-26T10:30:00Z",
"source_ip": "192.168.1.100",
"user_roles": ["administrator","power_user"]
最近更新时间:2025.10.13 15:11:19