欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

通过AWK 查看单机QPS

程序员文章站 2022-07-13 11:20:08
...
tail -f flm_sign_service_access_20191020.log |awk -F',' 'BEGIN{key="";count=0}/./{gsub(/{|\"/,"",$1);split($1,a,":");b=a[2]":"a[3]":"a[4];split(b,c,".");d=c[1];if(d==key){count++}else{print key" "count;count=1;key=d}}'

日志格式是这样的

{"datetime":"2019-10-20T18:04:52.437+0800","env":"release","log_type":"access","log_level":"NOTICE","app_name":"sign-service","uri":"/sign/getSignInfo","status":1,"hn":"ign-service-009","client_id":"","device_id":"","x_s_trace_id":"0f59c72a-96a6-4017-a9b9-a66fd234c49f","x_forwarded_for":"171.10747","remote_ip":"4","param_user_id":"123","param_sign_type":"2","http_code":"200","ms":"0.36907196044922"}

通过AWK 查看单机QPS

通过AWK 查看单机QPS