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!

Exciting News: The AppDynamics Community Joins Splunk!

Hello Splunkers,   I’d like to introduce myself—I’m Ryan, the former AppDynamics Community Manager, and I’m ...

The All New Performance Insights for Splunk

Splunk gives you amazing tools to analyze system data and make business-critical decisions, react to issues, ...

Good Sourcetype Naming

When it comes to getting data in, one of the earliest decisions made is what to use as a sourcetype. Often, ...