I want top 10 values from the below query:
Problem is , we have applied stats average on multiple column, so simply writing top 10 or head 10 won't work in this case. Sorting is also an issue in this case.
...
|stats avg(http_data) as "HTTP",avg(https_data) as "HTTPS",avg(rtsp_data) as "RTSP",avg(rtp_data) as "RTP",avg(wtp_data) as "WTP",avg(wsp_data) as "WSP",avg(mms_data) as "MMS",avg(sip_data) as "SIP",avg(ftp_data) as "FTP",avg(dns_data) as "DNS Lookups",avg(smtp_data) as "SMTP",avg(pop3_data) as "POP3",avg(imap_data) as "IMAP",avg(skype_data) as "SKYPE",avg(torrent_data) as "TORRENT",avg(msn_data) as "MSN",avg(yahoo_data) as "YAHOO",avg(ddlink_data) as "DDLINK" ,avg(jabber_data) as "JABBER",avg(ppstream_data) as "PPSTREAM",avg(steam_data) as "STEAM",avg(imesh_data) as "IMESH",avg(hamachivpn_data) as "HAMACHIVPN",avg(mute_data) as "MUTE",avg(pando_data) as "PANDO",avg(orb_data) as "ORB",avg(winny_data) as "WINNY",avg(slingbox_data) as "SLINGEBOX",avg(fasttrack_data) as "FASTTRACK"
If you basically have one row and loads of columns you can transpose the result and then work with one column.
If you basically have one row and loads of columns you can transpose the result and then work with one column.
Sort and head work perfectly, consider this as an example:
| gentimes start=-1 increment=5m | stats avg(starttime) as avg1 avg(endtime) as avg2 max(starttime) as max1 max(endtime) as max2 min(starttime) as min1 min(endtime) as min2 | transpose | sort - "row 1" | head 3
No, this will not work.Transpose will categorize all values in one column but still TOP or SORT command won't work here, as there will be no column name and data is different.