Splunk Search

How to extract a content or string between 2 strings

sekhar463
Path Finder

 AL9851 | Z1 | [https://example1.com/] recording played asia location is Down

AL9851 | Z1 | [http://alphabeta/] recording played from asia location is Down

AL9851 | Z1 | [http://alphabeta/] recording played from US location is Down

 

i have above log from that need to extract URL .as URL varies but content is same before and after URL .

 

Labels (3)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @sekhar463

the phrase from @bowesmana means that using the rex command you can extract a field from the entire raw log (without specifying any field) as in your case, or specifying a field.

Ciao.

Giuseppe

View solution in original post

0 Karma

sekhar463
Path Finder

thanks it works

but is both rex works as same 

| rex "^([^\|]+\|\s+){2}\[(?<URL>[^\]]+)\]"
| rex "\[(?<url>http[^\]]*)\]"

 

0 Karma

sekhar463
Path Finder

Thanks it works 

but what is it means parsing _raw field

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sekhar463

the phrase from @bowesmana means that using the rex command you can extract a field from the entire raw log (without specifying any field) as in your case, or specifying a field.

Ciao.

Giuseppe

0 Karma

sekhar463
Path Finder

Thank you

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @sekhar463,

good for you, see next time!

Ciao and happy splunking

Giuseppe

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

0 Karma

gcusello
SplunkTrust
SplunkTrust

@sekhar463,

you could try this:

| rex "^([^\|]+\|\s+){2}\[(?<URL>[^\]]+)\]"

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

Ciao.

Giuseppe

sekhar463
Path Finder

thanks 

that works

0 Karma

bowesmana
SplunkTrust
SplunkTrust

Use 

| rex "\[(?<url>http[^\]]*)\]"

assuming you are parsing _raw field

I am assuming your example has 3 rows with 3 urls. The field name extracted above will be url

 

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

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

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...