嗨,我有一个splunk消息,得到的文件名列表与路径在一个单一的字符串。我需要将所有的文件名提取到新的一行中。
留言内容
/opt/test/files/matched/test1.txt, /src/files/log/test.log, /opt/main/unmatched/test2.txt
需要获取一个ID的文件名
ID Filenames
1 test1.txt
test.log
test2.txt
2 <another list of names>
尝试使用mvexpand,但无法实现。
| eval FileNames=mvindex(split(split(Sourcefiles,","), "/"),-1)| table Id, FileNames |mvexpand FileName
虽然你可能会得到 split
来工作。rex
要简单得多。 这个run-anywhere查询就是一个例子。中的regex是 rex
将每个路径的文件名提取到一个多值字段中。 然后: mvjoin
将它们合并成一行。
| makeresults | eval Sourcefiles="/opt/test/files/matched/test1.txt, /src/files/log/test.log, /opt/main/unmatched/test2.txt"
`comment("Above just sets up test data")`
| rex field=Sourcefiles max_match=0 "\/(?<FileName>\w+\.?\w*)(?:,|$)"
| eval FileNames=mvjoin(FileName, " ")