Splunk Search

Need help to extract field from raw

bhaskar5428
Explorer

Please find the below attached screenshot and data sample i need to create 5 felids 
problem statement - old splunk query not working as logging pattern got changed

3/28/25
10:04:25.685 PM
 
2025-03-28T22:04:25.685Z INFO 1 --- [ool-1-thread-11] c.d.t.l.s.s.e.e.NoopLoggingEtlEndpoint : Completed generation for [DE, 2025-03-28, LOAN_EVENT_SDP, 1]. Number of records: 186

 

Need below 

 

index=*1644* container_name="ls2-sdp-java" $selected_countries$
| rex field=_raw "country=(?P<country>\w+)"    (DE)
| rex field=_raw "sdpType=(?P<sdpType>\w+)"  (LOAN_EVENT_SDP)
| rex field=_raw "cobDate=(?P<cobDate>\w+)"  (2025-03-28)
| rex field=_raw "record-count: (?P<Recordcount>\w+)" (186)
| rex field=_raw "\[(?<dateTime>.*)\] \{Thread"  (2025-03-28T22:04)
| eval DateTime=strptime(dateTime, "%Y-%m-%dT%H:%M:%S,%N")
| eval CreatedTime=strftime(DateTime, "%H:%M")
| eval CreatedDate=strftime(DateTime, "%Y-%m-%d")

above SPL has old query , can you please help me with new rex pattern to extract these fields 

For clear understanding i have attached required fields in screenshot

 

bhaskar5428_0-1743766654553.png

 

Labels (1)
0 Karma

livehybrid
SplunkTrust
SplunkTrust

Hi @bhaskar5428,

Check out the following:

index=*1644* container_name="ls2-sdp-java" $selected_countries$ 
| rex field=_raw "\[(?<country>[^,]+),\s(?<cobDate>[^,]+),\s(?<sdpType>[^,]+)," 
| rex field=_raw "Number of records:\s*(?<Recordcount>\d+)" 
| rex field=_raw "^(?<dateTime>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)" 
| eval DateTime=strptime(dateTime, "%Y-%m-%dT%H:%M:%S.%NZ") 
| eval CreatedTime=strftime(DateTime, "%H:%M") 
| eval CreatedDate=strftime(DateTime, "%Y-%m-%d")

Example with makeresults:

| makeresults 
| eval _raw="2025-03-28T22:04:25.685Z INFO 1 --- [ool-1-thread-11] c.d.t.l.s.s.e.e.NoopLoggingEtlEndpoint : Completed generation for [DE, 2025-03-28, LOAN_EVENT_SDP, 1]. Number of records: 186" 
| rex field=_raw "\[(?<country>[^,]+),\s(?<cobDate>[^,]+),\s(?<sdpType>[^,]+)," 
| rex field=_raw "Number of records:\s*(?<Recordcount>\d+)" 
| rex field=_raw "^(?<dateTime>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z)" 
| eval DateTime=strptime(dateTime, "%Y-%m-%dT%H:%M:%S.%NZ") 
| eval CreatedTime=strftime(DateTime, "%H:%M") 
| eval CreatedDate=strftime(DateTime, "%Y-%m-%d") 
| table _raw dateTime country cobDate sdpType Recordcount CreatedTime CreatedDate

 

🌟 Did this answer help you? If so, please consider:

  • Adding kudos to show it was useful
  • Marking it as the solution if it resolved your issue
  • Commenting if you need any clarification

Your feedback encourages the volunteers in this community to continue contributing

0 Karma

bhaskar5428
Explorer

Not working , But if use single and try for single Country its working 
please help 

bhaskar5428_0-1743769239520.pngbhaskar5428_1-1743769275246.png

also what is use of 

| rex field=_raw "^\S+"

 

richgalloway
SplunkTrust
SplunkTrust

Perhaps this will help.

index=*1644* container_name="ls2-sdp-java" $selected_countries$
| rex field=_raw "for \[(?P<country>\w+),\s*(?P<cobDate>\w+),\s*(?P<sdpType>\w+)"
| rex field=_raw "records: (?P<Recordcount>\w+)"
| rex field=_raw "^(?<dateTime>\S+)"
| eval DateTime=strptime(dateTime, "%Y-%m-%dT%H:%M:%S.%3N%Z")
| eval CreatedTime=strftime(DateTime, "%H:%M")
| eval CreatedDate=strftime(DateTime, "%Y-%m-%d")
---
If this reply helps you, Karma would be appreciated.
0 Karma

bhaskar5428
Explorer

Not working , please help 

 

| rex field=_raw "^\S+"

bhaskar5428_0-1743769391319.png

bhaskar5428_1-1743769432164.png

 

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please try my updated query.

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

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...