Splunk Search

rex help...

msarkaus
Explorer

Greetings,

Please help!!

I need to extract the ID value from the two events below, and I’m kinda banging my head here… . I just need to list Q123456789 and each ID in my dashboard. But it I can’t get past all of the special characters.

I’ve tried using different combinations like this:

| eval msg=”the event”

| rex "msg =(?< policyId >\w+)”

| table policyId

But what I would really like to have something like this in my dashboard:

Starting Controller Q123456789

CallStatus=Success Q123456789

Starting Controller Q123456788

CallStatus=Success Q123456788

Starting Controller Q123456787

CallStatus=Success Q123456787

And so on.

Is this possible?

Your help is always appreciated.

Thanks

 

 

Starting Controller=Fall Action=GetFallReportAssessment data={"policyId":"Q123456789","inceptionDate":"20250501","postDate":"1900-01-01T12:00:00"}

 

API=/api/Fall/reportAssessment/ CallStatus=Success Controller=Fall Action=GetFallReportAssessment Duration=27 data={"policyId":"Q123456789","inceptionDate":"20250501","postDate":"1900-01-01T12:00:00"}

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Regular expressions are very literal - they match exactly what they are told to match or they don't match at all.  In the attempted SPL, the rex command expects to find the letters 'm', 's',  'g', a space, and '=' in that order, but they are not present in the sample events so no policyId field can be extracted.  Try this

 

| rex field=msg "policyId\\\":\\\"(?<policyId>\w+)"

 

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

msarkaus
Explorer

Unfortunately, it didn't pick up the policy ID.  It returns a blank table

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Please share the full SPL you ran.  The one command I provided will not return a table so we need to know how you are creating a table.

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

ITWhisperer
SplunkTrust
SplunkTrust
| rex "\"policyId\":\"(?<policyId>\w+)\""
0 Karma

msarkaus
Explorer

It returns a blank table. 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If the rex isn't working, it is probably because it doesn't match precisely to the event you have. Please repost your events in a code block </> to preserve the formatting which will be important to getting the rex correct.

0 Karma

msarkaus
Explorer

</API=/api/full/reportAssessment/ CallStatus=Success Controller=Full Action=GetfullReportAssessment Duration=5 data={"policyId":"Q123456789","inceptionDate":"20241015","postDate":"1900-01-01T12:00:00"}>

 

</Starting Controller=Full Action=GetClueReportAssessment data={"policyId":"Q123456789","inceptionDate":"20241015","postDate":"1900-01-01T12:00:00"}/

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

This is a code block 

</API=/api/full/reportAssessment/ CallStatus=Success Controller=Full Action=GetfullReportAssessment Duration=5 data={"policyId":"Q123456789","inceptionDate":"20241015","postDate":"1900-01-01T12:00:00"}>

 

</Starting Controller=Full Action=GetClueReportAssessment data={"policyId":"Q123456789","inceptionDate":"20241015","postDate":"1900-01-01T12:00:00"}/

The rex pattern provided would extract the policyId from this so there is probably something different about the event as you have shown it and your actual events. If you don't provide accurate (enough) information, we will not be able to provide you with an accurate (enough) solution.

0 Karma

msarkaus
Explorer

Sorry.... I'm going to need to combine the policyid for both logs into one.  Both do not work.. 

Thanks again for your help..

Call out

</

index=xxx appSubLvlNam="QAA" (msgTxt="Starting Controller=Full Action=GetFullReportAssessment data*" OR msgTxt="API=/api/full/reportAssessment/ CallStatus=Success*")

| eval msgTxt "Starting Controller=Full Action=GetFullReportAssessment data={"policyId":"Q123456789","inceptionDate":"20241011","postDate":"1900-01-01T12:00:00"}"

| rex "\"policyId\":\"(?<policyId>\w+)\""

| table policyId

>

Response

</

index=xxx appSubLvlNam="QAA" (msgTxt="Starting Controller=Full Action=GetFullReportAssessment data*" OR msgTxt="API=/api/full/reportAssessment/ CallStatus=Success*")

| eval msgTxt "API=/api/full/reportAssessment/ CallStatus=Success Controller=full Action=GetFullReportAssessment Duration=17 data={"policyId":"Q123456789","inceptionDate":"20241015","postDate":"1900-01-01T12:00:00"} "

| rex "\"policyId\":\"(?<policyId>\w+)\""

| table policyId

>

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You need to provide your raw event in a code block - use this button

ITWhisperer_0-1729008984590.png

to open a code block and paste your raw event into it so we can see exactly what you are dealing with

0 Karma
Get Updates on the Splunk Community!

New This Month in Splunk Observability Cloud - Metrics Usage Analytics, Enhanced K8s ...

The latest enhancements across the Splunk Observability portfolio deliver greater flexibility, better data and ...

Alerting Best Practices: How to Create Good Detectors

At their best, detectors and the alerts they trigger notify teams when applications aren’t performing as ...

Discover Powerful New Features in Splunk Cloud Platform: Enhanced Analytics, ...

Hey Splunky people! We are excited to share the latest updates in Splunk Cloud Platform 9.3.2408. In this ...