Splunk Search

SPL

Muthu_Vinith
Path Finder

Hey Experts, I'm new to splunk and I'm trying to extract APP WEB and MNOPQ from a field called result. Can someone please guide me on how to achieve this? Any help or example queries would be greatly appreciated. Thank You!

Fi a:\abc\def\MNOPQ.txt content is expected to include "A H Dis Query,0,0"
Fi a:\abc\def\APP.txt content is expected to include "A H Dis Query,0,0"
Fi a:\abc\def\WEB.txt content is expected to include "A H Dis Query,0,0"
Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @Muthu_Vinith ,

you should use a regex like the following:

| rex field=result "\w:\\\w+\\\w+\\(?<myfield>[^\.]+)"

that you can test at https://regex101.com/r/BYH1rP/1

Ciao.

Giuseppe

View solution in original post

Muthu_Vinith
Path Finder

Hi @gcusello @ITWhisperer 

| rex field=result "\w:\\\\\w+\\\\\w+\\\\(?<myfield>[^\.]+)"

The above query extracts, but if i want to extract APP and WEB which is in same line how to extract ?

Fi a:\abc\def\
MNOPQ.txt content is expected to include "A H Dis Query,0,0"
Fi a:\abc\def\APP.txt content is expected to include "A H Dis Query,0,0" Fi a:\abc\def\WEB.txt content is expected to include "A H Dis Query,0,0"
Fi a:\abc\def\SQL.txt content is expected to include "A H Dis Query,0,0"

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Use max_match

| rex max_match=0 field=result "\w:\\\\\w+\\\\\w+\\\\(?<myfield>[^\.]+)"

Note that this will give you a multivalue field

Muthu_Vinith
Path Finder

Thanks @ITWhisperer 

0 Karma

yuanliu
SplunkTrust
SplunkTrust

@Muthu_Vinith Please use descriptive title.  This helps future users finding the answer.

0 Karma

Muthu_Vinith
Path Finder

Thanks!! @gcusello @ITWhisperer 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Muthu_Vinith ,

good for you, see next time!

let us know if we can help you more, or, please, accept one answer for the other people of Community.

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated by all the contributors 😉

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
| rex field=result "\w:\\\\\w+\\\\\w+\\\\(?<myfield>[^\.]+)"

gcusello
SplunkTrust
SplunkTrust

Hi @Muthu_Vinith ,

you should use a regex like the following:

| rex field=result "\w:\\\w+\\\w+\\(?<myfield>[^\.]+)"

that you can test at https://regex101.com/r/BYH1rP/1

Ciao.

Giuseppe

Get Updates on the Splunk Community!

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 ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

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