统计tomcat/nginx访问日志access

统计每分钟的访问量
awk -F: '{count[$2":"$3]++} END {for (minute in count) print minute, count[minute]}' /home/jyapp/apache-tomcat-7.0.59-interface/logs/localhost_access_log.2019-07-18.txt | sort
09:53 3
10:56 32531
10:57 7670
11:00 14920
11:01 20647
11:19 14185
11:20 10890
11:23 11917
11:24 10049
11:25 18582
11:26 792
11:27 11528
11:28 5979
11:31 47962
11:32 24836
11:33 30062
11:34 10216
11:35 16459
11:36 15487




统计响应时间超过1秒的请求
awk '($NF > 1000){print $0}' /home/jyapp/apache-tomcat-7.0.59-interface/logs/localhost_access_log.2019-07-18.txt
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-143"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-61"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 1908
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-172"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3454
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-88"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 1292
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-184"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 1908
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-185"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-39"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3453
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-59"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140
172.18.100.202 - - [18/Jul/2019:10:56:55 +0800] http-bio-8082-exec-166"POST /core-interface/api/wealth/3103/v1 HTTP/1.1" 200 3140



统计每个接口的请求次数
awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-07-18.txt | sort -bn
3	/manager/status/all?XML=true
304712	/core-interface/api/wealth/3103/v1



统计每个接口的请求次数并 从小到大排列
[jyapp@JY2XNTE03 logs]$ awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-05-18.txt |sort -n
1	/xqAppServer/api/APPBizRe172.18.100.202
1	/xqAppServer/api/APPBizRest/queryM172.18.100.202
288051	/xqAppServer/api/APPBizRest/queryBankWithdrawAmount/v1/
491024	/xqAppServer/api/APPBizRest/queryMyWealth/v1/
522403	/xqAppServer/api/APPBizRest/queryCreditorTransferInfo/v1/
697232	/xqAppServer/api/APPBizRest/queryCashCalendar/v1/



统计每个接口的请求次数,按大小排列,取top3
[jyapp@JY2XNTE03 logs]$ awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-05-18.txt |sort -n|head -n 3
1	/xqAppServer/api/APPBizRe172.18.100.202
1	/xqAppServer/api/APPBizRest/queryM172.18.100.202
288051	/xqAppServer/api/APPBizRest/queryBankWithdrawAmount/v1/




统计每个接口的请求次数,按从大到小排列
[jyapp@JY2XNTE03 logs]$ awk '{aaa[$7]++;} END{for(i in aaa) { printf("%s\t%s\n", aaa[i], i); }}' localhost_access_log.2019-05-18.txt |sort -t $'\t' -k1 -r
697232	/xqAppServer/api/APPBizRest/queryCashCalendar/v1/
522403	/xqAppServer/api/APPBizRest/queryCreditorTransferInfo/v1/
491024	/xqAppServer/api/APPBizRest/queryMyWealth/v1/
288051	/xqAppServer/api/APPBizRest/queryBankWithdrawAmount/v1/
1	/xqAppServer/api/APPBizRest/queryM172.18.100.202
1	/xqAppServer/api/APPBizRe172.18.100.202

 

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值