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!

Observability | How to Think About Instrumentation Overhead (White Paper)

Novice observability practitioners are often overly obsessed with performance. They might approach ...

Cloud Platform | Get Resiliency in the Cloud Event (Register Now!)

IDC Report: Enterprises Gain Higher Efficiency and Resiliency With Migration to Cloud  Today many enterprises ...

The Great Resilience Quest: 10th Leaderboard Update

The tenth leaderboard update (11.23-12.05) for The Great Resilience Quest is out &gt;&gt; As our brave ...