-
Notifications
You must be signed in to change notification settings - Fork 255
[urlparam]Transformer
redHJ edited this page Apr 17, 2018
·
3 revisions
该 transformer 可以解析带有 url parameter 格式的字符串(如uid=123&name=tom&age=10
或/mytest?uid=123&name=tom&age=10
),并将其转化为键值对填充到原数据中.
在Parser后使用,针对指定的字段做 url param 解析
{
"type":"urlparam",
"key":"urlParamFieldKey",
}
-
key
指定要解析的数据所在字段,支持多级嵌套,多级间用.
符号连接,如abc.xyz
,表示 data["abc"]["xyz"]中的数据。
{
"name":"test2.csv",
"reader":{
"log_path":"./tests/logdir",
"mode":"dir"
},
"parser":{
"name":"jsonps",
"type":"json"
},
"transforms":[{
"type":"urlparam",
"key":"params"
}],
"senders":[{
"name":"file_sender",
"sender_type":"file",
"file_send_path":"./test2/test2_csv_file.txt"
}]
}
例如, parser 解析后的数据为:
{
"field1": "aaaa",
"field2": "bbbb",
"params": "/mytest?uid=123&name=tom&age=10"
}
经过 urlparam transformer 变换后的数据将变为:
{
"field1": "aaaa",
"field2": "bbbb",
"params": "/mytest?uid=123&name=tom&age=10",
"params_uid": "123",
"params_name": "tom",
"params_age": "10",
"params_url_param_path": "/mytest",
}
- 当 url param 中扩展开来的字段名与数据中原有的字段名称冲突时,该 transformer 会在其扩展名后面添加数字以便区分, 例如:
解析后数据将变成:
{ "params_uid": "aaaa", "field2": "bbbb", "params": "uid=123&name=tom&age=10" }
{ "params_uid": "aaaa", "field2": "bbbb", "params": "uid=123&name=lily&age=10", "params_uid1": "233", "params_name": "lily", "params_age": "10" }
快速开始 | Pandora | Readers | Parsers | Senders | Download | 七牛智能日志管理平台 | logkit-pro专业版