Splunk Search

How to find the totals of status codes per uri per day?

Arjang
Explorer

I am using the following search:

( sourcetype=iis ) sc_status=500 |stats count by  uri_path sc_status date

but that only gives me the failures, I want the successes for them as well i.e. sc_status=200 or other sc_status

If I try :

( sourcetype=iis ) |stats count by  uri_path sc_status date

I get too many results that had never had 400, 500, i.e. the ur_path s that always were successful,
I just want the

( sourcetype=iis ) |stats count by  uri_path sc_status date

results sets that contain at least one sc_status >400

I tried using join, inner join (1)

 ( sourcetype=iis ) sc_status=500 |stats count by  uri_path sc_status date

with (2)

 ( sourcetype=iis ) |stats count by  uri_path sc_status date

I got this :

( sourcetype=iis ) sc_status=500 |fields  uri_path | join uri_path [search sourcetype=iis | fields uri_path,sc_status,date ] | stats count by uri_path , sc_status , date| sort -count

but the result does not contain any sc_status = 500

The result should be (2) where each one of the uri_path was in (1).
That means sc_status = 500 should also be included in the final result.
Maybe there is an alternative way of finding the totals of status codes per uri per day. I would be happy with just a result like so

uri_path,sc_"statusLessThan400","sc_statusGreaterThanOrEqualTo400",date
0 Karma
1 Solution

niketn
Legend

@Arjang, please try the following:

 sourcetype=iis ) sc_status=*
| stats count(eval(sc_status=200)) as Success count(eval(sc_status!=200)) as Failures by  uri_path sc_status date
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@Arjang, please try the following:

 sourcetype=iis ) sc_status=*
| stats count(eval(sc_status=200)) as Success count(eval(sc_status!=200)) as Failures by  uri_path sc_status date
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

Arjang
Explorer

Thank you!

I ended up using :

(sourcetype=iis ) sc_status=* CurrentWork | stats count(eval(sc_status=200)) as Success count(eval(sc_status!=200)) as Failures by  uri_path date | search Failures > 0 | fields uri_path, date, Success,Failures

niketn
Legend

Great... I am sorry I think I missed the second part of your question. Glad you figured it out 🙂

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

Arjang
Explorer

you did the hardest part, once there are results filtering was easy.

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...