unix 如何从日志文件中获取https响应代码的计数?

l0oc07j2  于 2022-11-04  发布在  Unix
关注(0)|答案(2)|浏览(130)

{"header":{"type":"auto_translation","ret_code":"error","time_cost":884.0,"request_id":"405793975c1d11edace9b9b631af62f4"},"message":"Translation error (20001), please retry later. Detail: RuntimeException - The length of source sentence is too long!!! - {\n "header": {\n "time_cost": 0.000297,\n "type": "auto_translation",\n "ret_code": "The length of source sentence is too long!!!"\n }\n}"}

am46iovg

am46iovg1#

从日志文件中剪切另一组块是非常容易的。使用下面的命令,它将完成您所要求的工作。

cat `ls -rt access-duration.log||tail -1|head -1`|awk '{print 
$4,$6,$7,$8,$9}'|cut -c2-|awk '{print $1" "$3}' FS='"'|awk '{print 
$1,$2":"$3,$4}' FS=":" OFS=" "|awk '{print $1,$2,$4}'|sed 's/\/Jan\// 
01 /;s/\/Feb\// 02 /;s/\/Mar\// 03 /;s/\/Apr\// 04 /;s/\/May\// 05 
/;s/\/Jun\// 06 /;s/\/Jul\// 07 /;s/\/Aug\// 08 /;s/\/Sep\// 09 
/;s/\/Oct\// 10 /;s/\/Nov\// 11 /;s/\/Dec\// 12 /'|awk '{print 
$3,$2,$1,$4,$5}'|sort|uniq -c|awk 'BEGIN { FS=" " }{print $4"."$3"."$2" 
"$5","$6","$1}'|gawk 'BEGIN{FS=","} {LN[$1]; HD[$2]; MX[$1,$2]=$3} END 
{ printf "%s","\n \n  Timestamp      "; for (i in HD) printf "|     
%s", i; print ""; for (j in LN) {printf "%s",j; for (i in HD) { if 
(MX[j,i] =="") { printf " | %5d",0 } else { printf " | %5d", MX[j,i] } 
} print "" } }' |sort

我只在下面的行中做了更改,并在$4 '{print $4,$6,$7,$8,$9}后替换为-1,它起作用了。

rbpvctlc

rbpvctlc2#

这两个sample_files有什么区别
不同之处在于 SampleLog_2.log 中时间戳之后的附加括号列。
以及需要更改什么命令才能得到预期的输出。
为了减少对不需要的色谱柱的依赖,您可以更换管道

cat `ls -rt SampleFile.log||tail -1|head -1` \
|awk '{print $4,$7,$8,$9,$10}' \
|cut -c2- \
|awk '{print $1" "$3}' FS='"' \
|awk '{print $1,$2":"$3,$4}' FS=":" OFS=" " \
|awk '{print $1,$2,$4}'

sed 's?.*\(../.../....\):\(..:..\):.. .*" \(...\).*?\1 \2 \3?' SampleFile.log

在接下来的阶段中,可能还有进一步简化的空间。

相关问题