Splunk Search

Can you help me with my regular expression extraction?

swetar
New Member

Can anyone please suggest to me how I can break this event...

PATH="/user/hive/datastore/xyz.db/file_name1"
PATH="/user/hive/datastore/xyz.db/file_name2"
PATH="/user/hive/datastore/xyz.db/file_name3"

Into this required output:

required output 
file_name1
file_name2
file_name3

Thanks in advance
swetar

0 Karma
1 Solution

Rob2520
Communicator
0 Karma

adonio
Ultra Champion

hello there,

try this search anywhere:

  | makeresults count=1
    | eval  PATH="\"/user/hive/datastore/xyz.db/file_name1\";\"/user/hive/datastore/xyz.db/file_name2\";\"/user/hive/datastore/xyz.db/file_name3\""
    | makemv PATH delim=";"
    | mvexpand PATH
    | table PATH
    | rename COMMENT as "above generates data, below is your solution"
    | rex field=PATH "\"\/(?<dir_1>[^\/]+)\/(?<dir_2>[^\/]+)\/(?<dir_3>[^\/]+)\/(?<dir_4>[^\/]+)\/(?<file_name>[^\"]+)"

screenshot:
alt text

0 Karma

swetar
New Member

Thank you for your reply. I was able to do this ,using the below expression

"\/(?[^\/]+)$"

Many thanks

0 Karma

swetar
New Member

Thank you for your reply . I tried in this way. But didn't worked. Can you please suggest me,where I am wrong .
sourcetype="XXXXXX"| mvexpand PATH
| table PATH
| rex field=PATH "\"\/(?[^\/]+)\/(?[^\/]+)\/(?[^\/]+)\/(?[^\/]+)\/(?[^\"]+)"

0 Karma

Rob2520
Communicator

alt text

0 Karma

swetar
New Member

Thank you for your reply. I was able to to do this ,using the below expression

"\/(?[^\/]+)$"

0 Karma

swetar
New Member

Thank you for your reply . I tried this way but didn't work. I am new to regular expression. Can you please suggest me with complete syntax.

Many thanks
Swetar

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...