Splunk Search

How to get fields extracted by two fields?

kc_prane
Communicator

 i need  the fields  extracted  by two fields 

1) Detail message  = before the comma ( I need the full description)

2) Count =  after the comma ( I need the digit count)

RAW Log starts from below :

DETAIL MESSAGE, COUNT

Index 0 out of bounds for length 0, 61

No Recipienet found in MDM based on the input parameters, 120

No record found with this document Id, 86

No Records Found with given search Criteria in DB, 52

query did not return a unique result: 2; nested exception is javax.persistence.NonUniqueResultException: query did not return a unique result: 2, 106

You do not currently manage any user roles in PERLSS there is no task data to display at this time, 96

Labels (2)
Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

It was not clear from the OP that the sample data was a single event rather than multiple events.  That means the regular expression matches multiple strings, but the rex command defaults to returning only the first.  Use the max_match option to override that.

 

 

| rex max_match=0 "(?<detailMessage>[^,]+), (?<count>\d+)"

 

 

This will produce multi-value fields. You'll then need to use mv commands/functions to work with the fields.

Let us know what results you want and we can try to be more specific.

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

View solution in original post

0 Karma

richgalloway
SplunkTrust
SplunkTrust

This should get you started

| rex "(?<detailMessage>[^,]+), (?<count>\d+)"
---
If this reply helps you, Karma would be appreciated.
0 Karma

kc_prane
Communicator

Thanks, @richgalloway. But here I am only getting the first line for the fields extracted  in the log

 

kc_prane_0-1647023504759.png

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You say you only get one line, but the screenshot shows 7 lines.

Please provide more information, including the query used and the props.conf settings for the sourcetype.

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

kc_prane
Communicator

 

Hi @richgalloway   I don't have much details of the props but the below screenshot shows the rex is working only for the first line.

kc_prane_0-1647028953208.png

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It was not clear from the OP that the sample data was a single event rather than multiple events.  That means the regular expression matches multiple strings, but the rex command defaults to returning only the first.  Use the max_match option to override that.

 

 

| rex max_match=0 "(?<detailMessage>[^,]+), (?<count>\d+)"

 

 

This will produce multi-value fields. You'll then need to use mv commands/functions to work with the fields.

Let us know what results you want and we can try to be more specific.

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

kc_prane
Communicator

Much appreciated mate for your help!. It worked for me.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...

Deep insights, no barriers: Splunk Observability Cloud Free Edition

As software delivery cycles continue to accelerate, observability shouldn’t be a luxury — it should be a ...

Monitoring AI Agents with Splunk Observability Cloud

Let’s say I’m running a travel planning AI app in production. A user asks for three concise hotel options in ...