Splunk Search

How to extract URI following rex command?

karthi2809
Builder

How to extract URI following rex command?
My field

URI=/v4/cp/members/summary?hcid=

AN5635356

&firstnm=ELLEN&lastnm=BRODBINE&dob=1962-01-02

My rex command :

| rex field=_raw "URI=/v4/cp/members/summary?(?[^ ]*)"

?hcid=AN5635356&firstnm=ELLEN&lastnm=BRODBINE&dob=1962-01-02

Expected output:
AN5635356

Tags (3)
0 Karma

vinod94
Contributor

Try this,

| makeresults 
| eval data="URI=/v4/cp/members/summary?hcid=AN5635356&firstnm=ELLEN&lastnm=BRODBINE&dob=1962-01-02" 
| rename data as _raw 
| rex field=_raw "hcid\=(?P<OUTPUT>[^\&]*)"

damien_chillet
Builder

You need to escape special characters such as / and ?

Try URI=\/v4\/cp\/members\/summary\?hcid=(?P<hcid>[^&]+)

The value will be stored in field hcid

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

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