Splunk Search

Search results help in getting hourly results?

kc_prane
Communicator

Hi I am using the below query and i need the results in hourly basis for the time i selected ?

 

"My Base search"   | fields TRAN_TIME_MS PAGE_ID PAGE_TITLE _time| eventstats perc99(TRAN_TIME_MS) as Percentile by PAGE_ID | where TRAN_TIME_MS <= Percentile | stats count avg(TRAN_TIME_MS) as avg_time max(TRAN_TIME_MS) as max_time by PAGE_ID,PAGE_TITLE, | eval avg_time=round(avg_time/1000,2) | eval max_time=round(max_time/1000,2)
| rename count as Total_Requests avg_time as Average(Seconds) max_time as Max_Time(Seconds) PAGE_ID as Page_ID PAGE_TITLE as Page_Description

 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

To get the results broken down by hour, first use the bucket command to group results into the hour they occur.  Then add _time as a group in the stats command.

"My Base search"
| fields TRAN_TIME_MS PAGE_ID PAGE_TITLE _time
| eventstats perc99(TRAN_TIME_MS) as Percentile by PAGE_ID 
| where TRAN_TIME_MS <= Percentile 
| bucket span=1h _time
| stats count avg(TRAN_TIME_MS) as avg_time max(TRAN_TIME_MS) as max_time by _time, PAGE_ID,PAGE_TITLE, 
| eval avg_time=round(avg_time/1000,2) 
| eval max_time=round(max_time/1000,2)
| rename count as Total_Requests avg_time as Average(Seconds) max_time as Max_Time(Seconds) PAGE_ID as Page_ID PAGE_TITLE as Page_Description

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

kc_prane
Communicator

Thanks @richgalloway this Helps.

 

richgalloway
SplunkTrust
SplunkTrust

To get the results broken down by hour, first use the bucket command to group results into the hour they occur.  Then add _time as a group in the stats command.

"My Base search"
| fields TRAN_TIME_MS PAGE_ID PAGE_TITLE _time
| eventstats perc99(TRAN_TIME_MS) as Percentile by PAGE_ID 
| where TRAN_TIME_MS <= Percentile 
| bucket span=1h _time
| stats count avg(TRAN_TIME_MS) as avg_time max(TRAN_TIME_MS) as max_time by _time, PAGE_ID,PAGE_TITLE, 
| eval avg_time=round(avg_time/1000,2) 
| eval max_time=round(max_time/1000,2)
| rename count as Total_Requests avg_time as Average(Seconds) max_time as Max_Time(Seconds) PAGE_ID as Page_ID PAGE_TITLE as Page_Description

 

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...