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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...