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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...