Splunk Search

Help with Field Extraction Using Regex

MaddyRaj
Engager

I have 2 requests here.

I am trying to extract and create a new field from logs.

Logs for request 1:

 

 

2023-06-30 02:36:32 [INFO] [c6ea0e48-e793-4c35-893e-ff1f253dbca0] {"method":"GET","path":"/api/v2/organizations/infrastructure/workspaces","format":"jsonapi","status":200,"duration":377.88,"view":263.86,"db":65.86,"uuid":"c6ea0e48-e793-4c35-893e-ff1f253dbca0","remote_ip":"10.37.23.55, 10.218.136.20","request_id":"c6ea0e48-e793-4c35-893e-ff1f253dbca0","user_agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36","user":"iamtfeprdadmin","organization":"infrastructure","dd"

 

 

Here I want to extract & create a new field "status"

Example: status=200

 

Request 2 Logs:

 

 

10.218.136.20 - - [30/Jun/2023:02:36:32 +0000] "GET /api/v2/runs/run-HtzBcKEKf8x75mVe/run-events?include=comment%2Cactor HTTP/1.1" 304 0 "https://terraform.srv.companyname.com.au/app/customer/workspaces/a01300-tfe-dev01-customer_infra_azure/runs/run-HtzBcKEKf8x75mVe" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"

 

 

 Here I want to extract & create a new field "org"

Example: org=customer

(Result of the org is next to app. ie. companyname.com.au/app/customer)

Please help

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
| rex "status\":(?<status>\d+)"
| rex "\/app\/(?<org>[^\/]+)"

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust
| rex "status\":(?<status>\d+)"
| rex "\/app\/(?<org>[^\/]+)"
Get Updates on the Splunk Community!

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...

Enterprise Security (ES) Essentials 8.3 is Now GA — Smarter Detections, Faster ...

As of today, Enterprise Security (ES) Essentials 8.3 is now generally available, helping SOC teams simplify ...