Splunk Enterprise Security

Getting incorrect data while I am using rex splunk

rashhvarikuti
New Member

I wrote below query to get the data and display in my dashboard. And I am getting results with correct data + getting additional data too.

Here is the query:

index=tap-prod sourcetype=prod jobId=e62-71c72ccb3aec diff
| rex field=_raw "\"diff\":(?.*)}+"
| spath input=message
| extract kvdelim=":" pairdelim="," message
| table fieldName path expValue actValue

Here is the data I am parsing:

{
  "tapName": "tapData",
  "tapUuid": "22015f427a12",
  "diff": {
    "actValue": "tap_actualValue",
    "address": ".@gmail.com",
    "diffType": "SAMPLE_DIFFERENCE",
    "expValue": "tap_expectedValue",
    "fieldName": "Sample",
    "fullPath": "/http://www.gmail.com/file",
    "path": "/send"
  }
}

While executing above query I am getting below results which is incorrect:

Results

(fieldName)         ( path )                       (expValue)                  (actValue)               (address)
address":.@gmail.com"  expValue":"tap_expectedValue   actValue":"tap_actualValue   testName":"someOtherVal  `Sample`                                                `/send`                                                 `tap_expectedValue`                          `tap_actualValue`
0 Karma

woodcock
Esteemed Legend

Like this:

| rex "(?ms)\"diff\":(?<message>.*)}+" 

As in this:

| makeresults 
| eval _raw="{
\"tapName\": \"tapData\",
\"tapUuid\": \"22015f427a12\",
\"diff\": {
\"actValue\": \"tap_actualValue\",
\"address\": \".@gmail.com\",
\"diffType\": \"SAMPLE_DIFFERENCE\",
\"expValue\": \"tap_expectedValue\",
\"fieldName\": \"Sample\",
\"fullPath\": \"/http://www.gmail.com/file\",
\"path\": \"/send\"
    }
}" 
| rex "(?ms)\"diff\":(?<message>.*)}+" 
| spath input=message 
| table fieldName path expValue actValue**
0 Karma

rashhvarikuti
New Member

Thank you for your quick reply.

I tried with above solution but getting same results.

0 Karma

to4kawa
Ultra Champion

UPDATE:

Sample:

| makeresults 
| eval _raw="{
   \"tapName\": \"tapData\",
   \"tapUuid\": \"22015f427a12\",
   \"diff\": {
     \"actValue\": \"tap_actualValue\",
     \"address\": \".@gmail.com\",
     \"diffType\": \"SAMPLE_DIFFERENCE\",
     \"expValue\": \"tap_expectedValue\",
     \"fieldName\": \"Sample\",
     \"fullPath\": \"/http://www.gmail.com/file\",
     \"path\": \"/send\"
       }
 }" 
| spath diff output=message 
| spath input=message 
| fields - _* message

Result:

actValue,address,diffType,expValue,fieldName,fullPath,path
tap_actualValue,.@gmail.com,SAMPLE_DIFFERENCE,tap_expectedValue,Sample,/http://www.gmail.com/file,/send

Recommend:

 index=tap-prod sourcetype=prod jobId=e62-71c72ccb3aec diff 
| spath path=diff output=message
| spath input=message
| fields - _* message
| table fieldName path expValue actValue address

Can you provide props.conf?

0 Karma

rashhvarikuti
New Member

Thank you for your reply.

I tried using with your solution but getting same results.

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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...