Splunk Search

How to add daily average response time to hourly average response timechart?

lostbeatnik01
Explorer

In order to meet customer reporting requirements I need the average response time per hour and per day across all days over a month. I'm having difficulty getting the layout needed to include a daily average response time in the last row, I've tried appendpipe but it doesn't seem to work well with chart and I'm having trouble getting stats to get the layout.

Layout:
04/01 04/02 04/03 .......
00:00 0.309 0.472 3.216 ......
01:00 0.309 0.472 1.816 ......
02:00 0.235 0.435 2.516 ......
etc .......... .......... ........ .......
22:00 0.235 0.435 2.316 ......
23:00 0.277 0.535 3.235 ......
Total 0.254 0.599 2.06 ...... <---I NEED THIS ROW

I'm also joining across two data records, but this is working fine. Below is what I have for using chart. Any ideas for how to get the TOTAL in the last row?

index="indexname" sourcetype="sourctypename" log_Type=Access urn="/site/page" host=server1 
| table session_Id response_Time _time | 
join type=left session_Id 
[search index="indexname" sourcetype="sourctypename" log_Type=System CustomValue=*  log_Level=W | table session_Id PlatformClientID ] | where PlatformClientID=1234 | 
eval time_day=strftime(_time,"%m" + "/" + "%d") | 
eval time_hour=strftime(_time,"%H:00") |
chart eval(round(avg(response_Time)/1000,3)) AS AvgResponseTimes by time_hour time_day | fillnull value="0.000"|
rename time_hour AS "TIME SLOT (ET)"
0 Karma
1 Solution

somesoni2
Revered Legend

Try this

 index="indexname" sourcetype="sourctypename" log_Type=Access urn="/site/page" host=server1 
 | table session_Id response_Time _time | 
 join type=left session_Id 
 [search index="indexname" sourcetype="sourctypename" log_Type=System CustomValue=*  log_Level=W | table session_Id PlatformClientID ] | where PlatformClientID=1234 | 
 eval time_day=strftime(_time,"%m" + "/" + "%d") | 
 eval time_hour=strftime(_time,"%H:00") |
 chart eval(round(avg(response_Time)/1000,3)) AS AvgResponseTimes by time_hour time_day | fillnull value="0.000"|
appendpipe [| stats average(*) as * | eval time_hour="TOTAL" ] |  rename time_hour AS "TIME SLOT (ET)"

View solution in original post

0 Karma

somesoni2
Revered Legend

Try this

 index="indexname" sourcetype="sourctypename" log_Type=Access urn="/site/page" host=server1 
 | table session_Id response_Time _time | 
 join type=left session_Id 
 [search index="indexname" sourcetype="sourctypename" log_Type=System CustomValue=*  log_Level=W | table session_Id PlatformClientID ] | where PlatformClientID=1234 | 
 eval time_day=strftime(_time,"%m" + "/" + "%d") | 
 eval time_hour=strftime(_time,"%H:00") |
 chart eval(round(avg(response_Time)/1000,3)) AS AvgResponseTimes by time_hour time_day | fillnull value="0.000"|
appendpipe [| stats average(*) as * | eval time_hour="TOTAL" ] |  rename time_hour AS "TIME SLOT (ET)"
0 Karma

lostbeatnik01
Explorer

That works great. How would I round avg of *

0 Karma

somesoni2
Revered Legend

You would need a foreach command for that. Your appendpipe subsearch will be this now (rest same, use the <> syntax as is, no need to replace it with anything)

... | appendpipe [| stats average(*) as * | foreach * [eval "<<FIELD>>"=round('<<FIELD>>',2)] | eval time_hour="TOTAL" ]
0 Karma

lostbeatnik01
Explorer

more accurate csv layout:

"TIME SLOT (ET)","04/20","04/21","04/24"
"09:00","0.000","0.472","2.816"
"10:00","0.309","0.341","2.516"
"11:00","0.346","0.000","0.670"
"12:00","0.328","0.570","0.000"
"13:00","0.293","1.740","0.672"
"14:00","0.350","0.000","0.000"
"15:00","0.166","0.551","0.220"
"16:00","0.360","0.304","0.257"
"17:00","0.129","0.200","0.286"
"22:00","0.197","0.000","0.000"
"23:00","0.000","0.000","0.945"
"TOTAL","0.1234","0.1234","0.1234" <--NEED TOTAL

0 Karma

lostbeatnik01
Explorer

More accurate csv example:

"TIME SLOT (ET)","04/20","04/21","04/24"
"09:00","0.000","0.472","2.816"
"10:00","0.309","0.341","2.516"
"11:00","0.346","0.000","0.670"
"12:00","0.328","0.570","0.000"
"13:00","0.293","1.740","0.672"
"14:00","0.350","0.000","0.000"
"15:00","0.166","0.551","0.220"
"16:00","0.360","0.304","0.257"
"17:00","0.129","0.200","0.286"
"22:00","0.197","0.000","0.000"
"23:00","0.000","0.000","0.945"
"Total","0.444","0.444","0.876"

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...