Splunk Search

How do I calculate the number of server requests in the last 2 minutes?

rajhemant26
New Member

Hello everyone.

Want to display the output only for the time which crosses 18 months (earliest time)

Tags (1)
0 Karma

renjith_nair
Legend

@rajhemant26,

If you just want the count for last 2 minutes, set the earliest time to last 2 minutes relative to current time and do a stats count on the data,
For eg.

host=werdw* sourcetype=dfgc_metric R=* earliest=-2m@m 
| eval host_type=case(host LIKE "%wap%", "WAP", host LIKE "%web%", "WEB", host LIKE "%task%", "TASK", 
                 host LIKE "%iin%", "IIN", host LIKE "%gen%", "GEN", host LIKE "%ion%","ION", 
                 host LIKE "%int%", "INT", host LIKE "%out%", "OUT", host LIKE "%rpt%", "RPT", 
                 host LIKE "%rpo%", "RPO", 1=1, "Other") 
| stats count as Request by host_type

You need to use bin/bucket only if you want to split the data into time bukcet of 2 mins for the last x minutes/hours.
streamstats is used when you need a moving sum/avg/otehr agg functions over data

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk, and empower your SOC to reach new heights! Duration: 1 hour  Prepare to ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...