使用awk根据多维度统计系统tps
业务简单日志格式:
[2017-08-28 01:00:00.523]transfer_search,7001045,1708271100083774377,20170827,,,,,,,,,,00131013,V4,86ms
[2017-08-28 01:00:00.602]transfer_search,7001045,1708271100083784363,20170827,,,,,,,,1708272323481880,,0000,V4,81ms
统计结果:
awk脚本:
接口tps统计(按天):
zcat spay_mpsp.log.20171101*|awk -F " |]|," '{gsub("\\.","\]")};{print $2,$4}'|sort|uniq -c |sort -nr |awk -F ' ' '{print $3,$1}'|awk '{if(a[$1]==""||a[$1]<$2)a[$1]=$2}END{for(n in a)print n"\t"a[n]}'> inftps20171101.log
商户tps统计(按天):
zcat spay_mpsp.log.20171101*|awk -F " |]|," '{gsub("\\.","\]")};{print $2,$5}'|sort|uniq -c |sort -nr |awk -F ' ' '{print $3,$1}'|awk '{if(a[$1]==""||a[$1]<$2)a[$1]=$2}END{for(n in a)print n"\t"a[n]}'> mertps20171101.log