Splunk Search

Data comparison: past 24 hours v. Week or Month

RedHonda03
Explorer

Greetings Splunk Community!

I've looked through the pages here and haven't been fortunate to find a working answer that matches what I'm looking for. I'm trying to compare an event within the past 24 hours against the average events seen in the past week or month. Below are some threads which seemed similar to my question.

https://community.splunk.com/t5/Splunk-Search/Using-timewarp-to-compare-average-of-last-30-days-to-c...

https://community.splunk.com/t5/Splunk-Search/Need-help-on-how-to-alert-if-daily-count-exceed-30-day...<---Unable to get this modified to work as desired

Below is a screenshot of the search and output.  It appears to me that the Eval statement is just taking the count of Today and dividing it by 7. It is not producing an actual 7 day average of the past week.

week.JPG

I feel like I'm overlooking something obvious, but at the moment it is escaping me.

Labels (2)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Try using eventstats

| gentimes start=-7 increment=1h
| eval _time=starttime
| eval count=random()%20


| timechart span=1d sum(count) as count
| timewrap week series=short
| eventstats avg(s*) as avg_s*
0 Karma

RedHonda03
Explorer

Thank you for taking some time to assist here!  Looking at what you have, I presume this is for your test instance. I'm not fully understanding why I would need to reduce the increments to such a a small value of just an hour. In addition, I'm trying to figure out the purpose of assigning the count a random value of 1-20. I have never used the random function before and according to the documentation it is taking a random value of 1-X and dividing it by X.

Just using what was shared, my search seems to fail. I've tried moving the lines around to get it to work, but have yet to find a working search.
Splunk1.JPGSplunk2.JPGSplunk3.JPGSplunk4.JPG

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The part before the blank lines generates some dummy data for the runanywhere example - the timechart in the example what changed to a sum(count) but you can use your own timechart command

0 Karma

RedHonda03
Explorer

Ah, that makes a little more sense.  I finally got a working query, thank you!

source="winevtlog:sec" EventCode=4625 earliest = -7d@d latest = @d
| timechart span=1d count
| timewrap week series=short
| eventstats avg(s*) as avg_s*
| table _time, _span, s0, avg_s0
| rename s0 AS Today avg_s0 AS "Weekly Average"

SplunkCapture.JPG

 

Now it's onto the visual clean-up of rounding to the whole number...

0 Karma
Get Updates on the Splunk Community!

Automatic Discovery Part 1: What is Automatic Discovery in Splunk Observability Cloud ...

If you’ve ever deployed a new database cluster, spun up a caching layer, or added a load balancer, you know it ...

Real-Time Fraud Detection: How Splunk Dashboards Protect Financial Institutions

Financial fraud isn't slowing down. If anything, it's getting more sophisticated. Account takeovers, credit ...

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...