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!

Fun with Regular Expression - multiples of nine

Fun with Regular Expression - multiples of nineThis challenge was first posted on Slack #regex channel ...

[Live Demo] Watch SOC transformation in action with the reimagined Splunk Enterprise ...

Overwhelmed SOC? Splunk ES Has Your Back Tool sprawl, alert fatigue, and endless context switching are making ...

What’s New & Next in Splunk SOAR

Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us on ...