admin管理员组文章数量:1352205
Given an event with a field that contains multiple values:
001003012002003xyz...
where each has the format
iiilllvvvvvv...
Where
i
=3-digit idl
=3-digit lengthv
=alphanumeric value of the length specified
I'd like to split this in Splunk such that I can apply logic like "event contains an id of 13" or "id 29 has a value of 'abc123'", etc.
Regular expressions do not seem to work here. Backreferences are not supported in reference counts, so something like (?<id>\d{3})(?<length>\d{3})(?<value>.{1,\<length>})
will not work.
I also tried all the eval functions in Splunk, but none of them seem to be able to split strings on anything other than regular expressions or fixed indexes, neither of which work here.
Given an event with a field that contains multiple values:
001003012002003xyz...
where each has the format
iiilllvvvvvv...
Where
i
=3-digit idl
=3-digit lengthv
=alphanumeric value of the length specified
I'd like to split this in Splunk such that I can apply logic like "event contains an id of 13" or "id 29 has a value of 'abc123'", etc.
Regular expressions do not seem to work here. Backreferences are not supported in reference counts, so something like (?<id>\d{3})(?<length>\d{3})(?<value>.{1,\<length>})
will not work.
I also tried all the eval functions in Splunk, but none of them seem to be able to split strings on anything other than regular expressions or fixed indexes, neither of which work here.
Share Improve this question edited Apr 1 at 3:32 Andrew Morris asked Apr 1 at 3:23 Andrew MorrisAndrew Morris 112 bronze badges New contributor Andrew Morris is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct. 1 |1 Answer
Reset to default 0Something like below:
| makeresults
| eval _raw="123005dfghyujikol;"
``` the above is test data ```
``` below the actual query ```
| rex (?<id>\d{3})(?<lng>\d{3})(?<therest>.*)
| eval value=substr(therest, 1, lng)
(Hopefully no typos)
本文标签: splunkSplit field based on length in the fieldStack Overflow
版权声明:本文标题:splunk - Split field based on length in the field - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743910039a2560225.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
substr()
? See if this helps any: community.splunk/t5/Splunk-Search/… – PM 77-1 Commented Apr 1 at 18:58