Splunk Search

Extract a part of field

Olivier2024
Explorer

Hi all,

I'm trying to extract a part of a field. The field named Computer and is like MySrv.MyDomain.MySubDom1.com

MySubDom1 can exist or not.

I would like to extract everything after MySrv. I tried with  index=MyIndex host=MySrv | rex field=_raw "(?<domaine_test>(\.\w+))"

The result create a new field Domain_test but it stores only the first part "MyDomain" and not the rest of the field.

How can I do this ?

For exemple :

Computer = "MySrv.MyDomain.MySubDom1.com"
Result : Domain_test = "MyDomain.MySubDom1.com"

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\w+\.(?<domaine_test>[\.\w-]+)"

if the - is at the end of the character class [] it doesn't need to be escaped

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\w+\.(?<domaine_test>[\.\w]+)"
0 Karma

Olivier2024
Explorer

Hi,

Thank you for your response.

I have some domain with "-" character, for exemple black-ice.com
The result is "black". Is it possible to get all domain ?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\w+\.(?<domaine_test>[\.\w-]+)"

if the - is at the end of the character class [] it doesn't need to be escaped

Olivier2024
Explorer

It works 🙂

Many thanks for your help !

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...