Agnus Dei (jackal) wrote,
Agnus Dei
jackal

using awk to make histogram data of response times from your HTTP access log

In this example I'm using an access log that ends with the string "millis".

For example, a tomcat access log (doesn't matter the type of access log):


123.123.123.123 XXXXXX.XXXX.com - - [22/Oct/2015:00:00:03 +0000] GET /happy/dance HTTP/1.1 200 21 - "XXXX/4.9.2 (iPad; iOS 8.3; Scale/2.00)" lalala lalala "-" http-8443-21 - 8 millis

Since I know the time is in millis, and I want to group by 0-5 seconds, 5-10 seconds, 10-15 seconds... etc.

$ zcat access_log.2015-10-21.txt.gz | awk -vL=5000 '$NF=="millis" { ++b[i=int($(NF-1)/L)] ; if(i>m) m=i } END  { for(i=0;i<=m;i++) print "["i*L/1000","(i*L+L)/1000"]",b[i] }'
[0,5] 677608
[5,10] 1240
[10,15] 153
[15,20] 33
[20,25] 26
[25,30] 17
[30,35] 16
[35,40] 11
[40,45] 3
[45,50] 1
[50,55]
[55,60] 2
[60,65]
[65,70]
[70,75] 1
[75,80]
[80,85]
[85,90]
[90,95]
[95,100]
[100,105]
[105,110]
[110,115] 1
[115,120] 1
[120,125]
[125,130] 1
[130,135]
[135,140]
[140,145]
[145,150] 1
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments