Splunk Search

What is the regex for the following output ?

JyotiP
Path Finder

Query :
"POST" "200" "api/platform/v1/Session" FirmName

Output:
Level="INFO", Date="2017-12-12 04:06:26,200", Message="GET session API complete.", JobType="GetSession", TimeSpan="14ms", URL="http://test:8080/v1/session", ActivityId="70a51b98-365f-4882-94c7-9563d465b211", Header="{"Authorization":"**","UserSession":{"FirmId":10017,"UserId":20,"FirmName":" Test2","UserName":"AutomationTests","UserSessionToken":"**","FirmAuthToken":"T4QV4","EnvironmentName":"AWSPROD"},"TransactionId":"7c257e48-3816-48bc-a717-fe96f5c33271","X-Request-Id":"70a51b98-365f-4882-94c7-9563d465b211","X-Operation":"{\"OperationId\":\"fa255617-2fae-44d7-9b16-8813f35d12a3\",\"OperationName\":\"Post to IBOR\"}","X-Trace":"0"}", OperationId="fa255617-2fae-44d7-9b16-8813f35d12a3", OperationName="Post to IBOR", Product="CoreData", Stack="core-data", Service="graphql", AppDomain="core-data_graphql"

I just want to fetch the FirmName value then what would be the regext for it.Basically I want to fetch "Test2" in output. How would I do it ?

Tags (1)
0 Karma

niketn
Legend

@JyotiP, you can try the following regex

<YourBaseSearch>
| rex "\"FirmName\":\"(?<firmName>[^\"]+)\""

However, seems like you have JSON data, so it is better if you try rex to get complete JSON Data packet and then apply spath command.
You should also try out couple of props.conf properties like INDEXED_EXTRACTION=json and/or KV_MODE=json

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

mayurr98
Super Champion

hey @JyotiP

Try this :

 index=your_index | rex field=_raw "FirmName\"\:\"\s+(?P<FirmName>[^\"]+)"

OR 

 index=your_index | rex field=_raw "FirmName\"\:\"(?P<FirmName>[^\"]+)"

Let me know if it helps!

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 ...