Splunk Search

% failures for each day during the time range selected

VS0909
Communicator

Need help with a Splunk query  to display % failures for each day during the time range selected

% failures = A1/A2 *100

A1= Total number of events returned by the below query:

index="abc"  "searchTermForA1"

 

A2= Total number of events returned by the below query:

index="xyz"  "searchTermForA2"

 

Expected Output:

-------Date-------|--------A1-------------|------A2----------|-----% failures-------

Separate rows in the result set for date 1-Jul, 2-Jul, 3-Jul, 4-Jul, 5-Jul, 6-Jul and 7-Jul, for time range selected as 1Jul to 7-Jul.

Please help with the query.

Thanks!

Labels (6)
0 Karma

VS0909
Communicator

@ITWhisperer  Thanks for the reply! 

I also have a scenario where I need to find % failure for each day during the time range selected, for same index but different search term

% failures = A1/A2 *100

A1= Total number of events returned by the below query:

index="abc"  "searchTermForA1"

 

A2= Total number of events returned by the below query:

index="abc"  "searchTermForA2"

Please help.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

It will depend on what "searchTermForA1" and "searchTermForA2" actually are and possibly what your events actually look like

0 Karma

VS0909
Communicator

@ITWhisperer   

searchTermForA1 = "A1_API_Failed"

searchTermForA2="TESTSTRING" "https://aaa.com/v1/?bbb"

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index="abc" "searchTermForA1"
| bin _time span=1d
| stats count as A1 by _time
| append [| search index="abc" "searchTermForA2"
     | bin _time span=1d
     | stats count as A2 by _time
     ]
| stats values(*) as * by _time
| eval failures=100*A1/A2

ITWhisperer
SplunkTrust
SplunkTrust
(index="abc" "searchTermForA1") OR (index="xyz" "searchTermForA2")
| bin _time span=1d
| stats count(eval(index="abc")) as A1 count(eval(index="xyz")) as A2 by _time
| eval failures=100*A1/A2
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 ...