Splunk Search

how can i calculate the average time range of DayOne,DayTwo,DayThree for each student_id?

pavanae
Builder

I have a splunk Query as below

earliest=-1d@d latest=@d index=abc | where date_hour>=15 OR date_hour<9 | stats earliest(date_hour) as FirstHour latest(date_hour) as LastHour by student_id|eval DayOne=FirstHour+" to "+LastHour| fields - FirstHour - FirstMinute - LastHour - LastMinute | appendcols [search earliest=-2d@d latest=-1d@d index=abc | where date_hour>=15 OR date_hour<9 | stats earliest(date_hour) as FirstHour latest(date_hour) as LastHour by student_id|eval DayTwo=FirstHour+" to "+LastHour| fields - FirstHour - FirstMinute - LastHour - LastMinute ] | appendcols [search earliest=-3d@d latest=-2d@d index=abc | where date_hour>=15 OR date_hour<9 | stats earliest(date_hour) as FirstHour latest(date_hour) as LastHour by student_id|eval DayThree=FirstHour+" to "+LastHour| fields - FirstHour - FirstMinute - LastHour - LastMinute ]| table student_id DayOne DayTwo DayThree

Which displays the result as below

student_id DayOne DayTwo DayThree
A123 22--24 19--23 20--22
B456 02--08 03--07 19--00

Hint 1 :- I have used 3 searches above which are same except for the fields DayOne,DayTwo,DayThree and earliest,latest times.

Note :- If calcullating average for this scenario isn't possible. Any ideas or suggestions would highly appriciate. Thank you.

Now how can i calculate the average time range of DayOne,DayTwo,DayThree for each student_id?

0 Karma

gokadroid
Motivator

Looks like the average calculation for your data set was already provided which you had accepted as an answer too, here:
https://answers.splunk.com/answers/475177/how-to-calculate-the-average-and-standard-deviatio.html

Also in this answer you have given a way to calculate the average yourself:
https://answers.splunk.com/answers/476004/how-to-compare-the-last-7-days-average-with-yester.html

Also as a comment to your scenario, you were not able to provide, what is the expected "average" that you wanted?
https://answers.splunk.com/answers/475177/how-to-calculate-the-average-and-standard-deviatio.html#co...

So unless you do not articulate what is meant by an average of the two dimensional data set that you provide then it might be hard to answer or to calculate it by community users.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...