Splunk Search

How to create a graph or table for the following query according to the Status Code ?? Please refer the result below.

JyotiP
Path Finder

{"StatusCode":200,"ReasonPhrase":"OK","Method":"POST","PathAndQuery":"}
{"StatusCode":404,"ReasonPhrase":"Not Found","Method":"GET","PathAndQuery":"}
{"Message":"Completed request to Create Position Events.","}.

For the above I have three categorize like status code 200, 400 and NONE. So I want to create a graph or count on the basis of Status Code. How to do it ??

0 Karma
1 Solution

DalJeanis
Legend

This will get you a bar graph...

 your base search that gets the records you want with StatusCode and _time
 | fillnull value="None" StatusCode
 | stats count by StatusCode

This will get you a chart over time...

your base search that gets the records you want with StatusCode and _time
| fillnull value="None" StatusCode
| timechart count by StatusCode

View solution in original post

0 Karma

DalJeanis
Legend

This will get you a bar graph...

 your base search that gets the records you want with StatusCode and _time
 | fillnull value="None" StatusCode
 | stats count by StatusCode

This will get you a chart over time...

your base search that gets the records you want with StatusCode and _time
| fillnull value="None" StatusCode
| timechart count by StatusCode
0 Karma

JyotiP
Path Finder

@DalJeanis, thanks for the update, will try the above two.

niketn
Legend

@JyotiP, are these indexed as single event or separate events?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

JyotiP
Path Finder

@niketnilay, these are separate events.

0 Karma

niketn
Legend

Please try the following:

<YourBaseSearch>
| rex field=_raw "{\"StatusCode\":(?<StatusCode>[^,]+),"
| stats count by StatusCode

Can you also add example for StatusCode None?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

JyotiP
Path Finder

@niketnilay, thanks for the update, will try the above.

0 Karma
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...