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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...