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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...