Splunk Search

typical week base on month data

JakubJ
Explorer

Hello,

I'm trying to chart typical week of our web application users based on data from last 4 weeks. Idea is, roughly explained, that I would calculate sum of request group (login, user accounts, etc - already done) per day and then created some type of "7 day window" in which there would be (seen in a graph) only 7 days but each day would be average of that day from last month.

So in a graph there would be (for example in case of request_group='login'):

Monday - 10 - which si average of sum in all mondays (10, 10, 5, 15, 10)
Tuesday - 8 - which is avg of sum in all tuesdays (8, 10, 6, 8, 😎
...and so on up until Sunday

part of my search is:

host "server" sourcetype="access_combined"
... some eval stuff ...
| fields _time request_group
... here should by magic calculating data ...

Thank you in advance. I've already tried different approach using streamstats or timewrap, but nothing worked as I intended.

Labels (3)
0 Karma
1 Solution

thambisetty
SplunkTrust
SplunkTrust
index=_internal sourcetype=splunkd_access
| bin _time span=1d
| stats count by date_wday,_time
| stats avg(count) as average by date_wday
————————————
If this helps, give a like below.

View solution in original post

0 Karma

thambisetty
SplunkTrust
SplunkTrust
index=_internal sourcetype=splunkd_access
| bin _time span=1d
| stats count by date_wday,_time
| stats avg(count) as average by date_wday
————————————
If this helps, give a like below.
0 Karma

JakubJ
Explorer

thank you for your hint. I was able to include this into my search, so last part in my case looks like this:

 

host "server" sourcetype="access_combined"
... some eval stuff ...
| fields date_wday _time request_group
| search request_group!="other"
| bin _time span=1d
| stats count by date_wday,request_group,_time
| chart avg(count) as prumer by date_wday,request_group
| eval sort_field = case(date_wday=="monday", 1,
    date_wday=="tuesday", 2,
    date_wday=="wednesday", 3,
    date_wday=="thursday", 4,
    date_wday=="friday", 5,
    date_wday=="saturday", 6,
    date_wday=="sunday", 7)
| sort 0 sort_field

 

 

sorting is based (coppied 🙂 ) from https://community.splunk.com/t5/Splunk-Search/Days-in-Alphabetical-Order-but-need-to-be-in-day-order...

0 Karma

thambisetty
SplunkTrust
SplunkTrust

please like my answer if it solves your problem.:)

————————————
If this helps, give a like below.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...

Modernize your Splunk Apps – Introducing Python 3.13 in Splunk

We are excited to announce that the upcoming releases of Splunk Enterprise 10.2.x and Splunk Cloud Platform ...

Step into “Hunt the Insider: An Splunk ES Premier Mystery” to catch a cybercriminal ...

After a whole week of being on call, you fell asleep on your keyboard, and you hit a sequence of buttons that ...