Splunk Search

How to access the last log item in array

graziaedu
Explorer

I have this log

{ [-]
   duration3005
   finishTime2021-08-25T15:47:26.838196
   loggersplunk
   startTime2021-08-25T15:47:23.832269
   stepTransitionDuration: [ [+]
   ]

   traceSteps: [ [-]
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     { [+]
     }
     [-]
       logTypeinfo
       messageResponse
       res: { [-]
         httpStatus400
       }

       timestamp2021-08-25T15:47:26.838195
       titleResponse
     }
   ]

   xrayTraceId:

}

 

How can i access only the last item (in bold letter)?

I tried to access with mvindex but return blank results.

0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| spath path=traceSteps{} output=traceSteps
| eval lasttrace=mvindex(traceSteps,-1)
| spath input=lasttrace

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try something like this

| spath path=traceSteps{} output=traceSteps
| eval lasttrace=mvindex(traceSteps,-1)
| spath input=lasttrace
0 Karma

graziaedu
Explorer

Thanks @ITWhisperer 

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...