Splunk Search

How to group by a field when the values have random words in between?

arnabsen1234
New Member

I have a field which has a random value in between (value can be anything. representing it by * here).

Field= test_field
value: test/documents/*/check

How do I group by this field since the value is always different and gives me different rows when I try to group by field test_field?

Tags (2)
0 Karma

woodcock
Esteemed Legend

Like this:

... | rex field=test_field "^(?<firstHalf>(?:[^/]+/){2})[^/]+/(?<secondHalf>.*)$" | eval Normalized_test_field = firstHalf . "*/" . secondHalf | stats <somestuff> BY Normalized_test_field

woodcock
Esteemed Legend

If this worked, please do click "Accept".

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...