Splunk Search

Unable to create field using regex

sagar_shubham
Explorer

Hi Team, 

 

Need your help in creating regex to create a field. 

"User_Claim":("sub":"qweihaytej"; "login_id":"Abc@domain.com";........) 

Here User_Claim is a field. I have to create a field for login_id.

I have tried with this, and it's not working. 

..... | rex field=User_Claim " login_id"(? <loginID>\w+.) "

I am unable to see the field name in the interesting fields. 

 

Please suggest in this. 

 

Thanks

Sagar

 

 

 

Labels (3)
0 Karma

ashvinpandey
Contributor

@sagar_shubham Try using the below rex:

| rex field=_raw "login_id\"\:\"(?P<login_id>.*?)\""

Also if this reply helped you in solving your problem an up-vote would be appreciated 👍

0 Karma

richgalloway
SplunkTrust
SplunkTrust

That regex has a few extra characters in it (and some missing ones) that prevent a match.  Also, "\w+" won't match the full login_id field because of the "@" (which is not a word character).  Finally, embedded quotation marks need to be escaped.  Try this command:

| rex field=User_Claim "login_id\\\":\\\" \\\"(?<loginID>[^\\\"]+)"

 

---
If this reply helps you, Karma would be appreciated.
0 Karma

sagar_shubham
Explorer

This is not working Sir. 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Meaning what, exactly?  Please share the full query you tried, what results were expected, and what results you got.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...