【发布时间】:2019-01-23 11:46:59
【问题描述】:
我正在尝试通过正则表达式(rex 命令)从原始数据中提取新字段。我的正则表达式在 splunk 网络搜索栏中运行良好并获得结果。但不能使用 REST api curl 作为客户端。
我想从 csv 数据集 train.csv 中提取一个字段,并希望将其命名为“数字”
curl -u admin:password -k https://localhost:8089/services/search/jobs -d search="search source=train.csv|rex field=_raw '^(?:\[^\"\\n\]*\"){2},\\w+,\\d+,\\d+,\\d+,\\d+,\\d+\\.\\d+,(?P<numbers>\[^,\]+)'| top numbers"
通过执行这个命令我得到了 sid
<?xml version="1.0" encoding="UTF-8"?>
<response>
<sid>1548238904.70</sid>
在询问结果后我得到了错误
curl -u admin:password -k https://localhost:8089/services/search/jobs/1548238904.70/results
Error in 'rex' command: The regex ''^(?:\[^\n\]*){2}' does not extract anything. It should specify at least one named group. Format: (?<name>...).</msg>
什么是命名组,为什么它在 splunk 搜索栏中运行良好
我想要以“数字”作为列或新字段的结果
【问题讨论】: