Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

splunk : json spath extract

| makeresults | eval data="{"Failure":0,"Success":0,"In_Progress":0,"Others":1,"detail":[{"jobA":{"STATUS":"Unavailable"}}]}
{"Failure":0,"Success":1,"In_Progress":0,"Others":1,"detail":[{"jobA":{"STATUS":"SUCCESS","Run":435988393},"jobB":{"STATUS":"Unavailable"}}]}" | eval data=split(data,"
") | mvexpand data | eval _raw=data
```Above just creates test data.  Omit IRL```
```Get the detail element from the events```
| spath path=detail{}
```Parse the details```
| spath input="detail{}"
```Parse the job and status fields as a unit.  We may have more than one.```
| rex field="detail{}" max_match=0 "(?<jobStatus>[^"]+":{"STATUS":"[^"]+)"
```Create a separate event for each match```
| mvexpand jobStatus
```Parse the job and status values from each match```
| rex field=jobStatus "(?<Job>[^"]+)":{"STATUS":"(?<Status>[^"]+)"
```Filter for unavailable jobs```
| where Status="Unavailable"
| table Job
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript get value outside function 
Javascript :: get the character code in a string 
Javascript :: restrict file input with react uploady 
Javascript :: JOLT split flat object into key/value array 
Javascript :: socket.io authentication 
Javascript :: error first callback in node js 
Javascript :: C# Convert Json File to DataTable using Newtonsoft.Json DLL 
Javascript :: insert image in jsp page 
Javascript :: Javascript array of array loop 
Javascript :: mustache tutorial javascript 
Javascript :: coercion in javascript mdn 
Javascript :: how can do i open the select tag using keyboard event using javascript site:stackoverflow.com 
Javascript :: javascript looping through array 
Javascript :: Setting Multiples Properties With Array 
Javascript :: add attribute to element in jquery 
Javascript :: ms dyn crm associate n:m record js 
Javascript :: phaser add camera 
Javascript :: react console logs not working 
Javascript :: arithmetic 
Javascript :: unhide is not working with radio button javascript 
Javascript :: var logNums = function(num) {}; 
Javascript :: animation in react stack overflow 
Javascript :: vue append component to div 
Javascript :: Backbone Collection 
Javascript :: how to properly make the navbar to be fixed to the top in react.jsx 
Javascript :: Solution-1--solution options for reverse bits algorithm js 
Javascript :: empty an array in javascript 
Javascript :: javascript get object methods 
Javascript :: react native new project 
Javascript :: traversing in jquery 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =