Splunk Search

How to get the values for time_hour?

abhi04
Communicator

I have a below query, which displays the Success, Failure, Total and Failure_Percent by time_hour. It only displays the value for the hour for which we have failure. I want t to display Failure for the time_hour for which it is zero also. Please help me on the same. Below is the query:

index=auto_prod_okta eventType="user.session.start" outcome.result="SUCCESS" earliest=@d | eval time_day = strftime(_time, "%D") | eval time_hour = strftime(_time, "%H")
| stats count(actor.alternateId) as Success by time_hour| join [search index=auto_prod_okta eventType="user.session.start" outcome.result="FAILURE" NOT "outcome.reason"=INVALID_CREDENTIALS NOT "outcome.reason"=LOCKED_OUT NOT "outcome.reason"=PASSWORD_BASED_LOGIN_DISALLOWED NOT "outcome.reason"="GENERAL_NONSUCCESS" NOT "outcome.reason"="null" earliest=@d| eval time_hour = strftime(_time, "%H") | stats count(actor.alternateId) as Failure by time_hour|fillnull value=0 ] |eval Total=(Success+Failure) | eval Failure_Percent=round((Failure/Total)*100,4) | table time_hour, Success, Failure, Total, Failure_Percent

0 Karma

FrankVl
Ultra Champion

You can achieve that by timecharting the data, rather than doing a stats. Also: I think the overall search can be restructured a lot.

Try this:

index=auto_prod_okta eventType="user.session.start" ( outcome.result="SUCCESS" OR (outcome.result="FAILURE" NOT "outcome.reason"=INVALID_CREDENTIALS NOT "outcome.reason"=LOCKED_OUT NOT "outcome.reason"=PASSWORD_BASED_LOGIN_DISALLOWED NOT "outcome.reason"="GENERAL_NONSUCCESS" NOT "outcome.reason"="null") ) earliest=@d 
| timechart count(actor.alternateId) by outcome.result span=1h
| eval time_hour = strftime(_time, "%H")
| eval Total=(SUCCESS+FAILURE)
| eval Failure_Percent=round((FAILURE/Total)*100,4)
| table time_hour, SUCCESS, FAILURE, Total, Failure_Percent
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...