Splunk Search

How to extract URI following rex command?

karthi2809
Contributor

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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...