Splunk Search

Filter events in a time frame by a condition

RemyaT
Explorer

I have the query to find the response code and count vs time (in 1 minute time interval) as below.

 

index=sample_index path=*/sample_path* 
	| bucket _time span=1m 
	| stats count by _time responseCode

 

The result shows the response code and count vs time for each minute. But I just need the events in those 1 minutes which have 403 response code along with other response codes and skip which doesn't have 403. 

Suppose during time1, if there are only events with response code 200, I don't need that in my result. But during time2, if there are events with response code 200 and 403, I need that in the result as time, response code, count. 

Labels (2)
Tags (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index=sample_index path=*/sample_path* responseCode=200 OR responseCode=403
| timechart span=1m count by responseCode
| where '403' > 0

gcusello
SplunkTrust
SplunkTrust

Hi @RemyaT,

let me understand: do you want to count only events with response_code=403 or cout of all response_codes when there's at least one 403?

If the first, you can try:

index=sample_index path=*/sample_path* response_code=403
| timechart span=1m count

if the second

index=sample_index path=*/sample_path* 
| bucket _time span=1m 
| stats 
   count(eval(response_code="200")) AS 200_count 
   count(eval(response_code="403")) AS 403_count 
   BY _time
| where 403_count >0

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...