Splunk Search

transforms.conf extract part of sourcepath

ryastrebov
Communicator

Hello Splunkers!

My eventdata places on folders:

/folder1/subfolder1/123/log1.log
/folder1/subfolder1/234/log2.log
/folder1/subfolder1/45/log2.log

My transforms.conf:

 [route-index1]
 SOURCE_KEY=source
 REGEX=???
 DEST_KEY=_TCP_ROUTING

I need to extract by REGEX part of source path - 123, 234, 45

Can You help me?

Best regards,
Roman

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Try this:

\/[\s\S]+\/[\s\S]+\/([\s\S]+)\/[\s\S]+
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this:

\/[\s\S]+\/[\s\S]+\/([\s\S]+)\/[\s\S]+
---
If this reply helps you, Karma would be appreciated.
0 Karma

ryastrebov
Communicator

Thank you for quick answer!

And if this part contain literal? For example:

 /folder1/subfolder1/foo123/log1.log
 /folder1/subfolder1/234boo/log2.log
 /folder1/subfolder1/foo45/log2.log

?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If it is the third part of the file path you seek then the same answer applies. If you seek only the numeric part of that path, you can modify the regex to get it. RegExr is a good tool for experimenting with regex strings.

---
If this reply helps you, Karma would be appreciated.
0 Karma

ryastrebov
Communicator

Thank you!

0 Karma
Get Updates on the Splunk Community!

Combine Multiline Logs into a Single Event with SOCK - a Guide for Advanced Users

This article is the continuation of the “Combine multiline logs into a single event with SOCK - a step-by-step ...

Everything Community at .conf24!

You may have seen mention of the .conf Community Zone 'round these parts and found yourself wondering what ...

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...