原始日志:
{"code":1,"msg":"ok","data":{"rows":[{"hostName":"a04_valchainnode_service_pro_v_tky","packMeta":"MXxNVFkzTVRNMk5qRTBOREEzTkRrME1UYzNOQT09fDF8MA","moduleName":"val","serverName":"aliyun2","content":"content:I[2022-12-27|07:41:18.550][1] <font color=\"red\">Height</font><<font color=\"red\">16281458</font>>, Tx<1>, SimTx<16281459:1>, BlockSize<2232>, BTInterval<3802ms>, LastBlockTime<3800ms>, GasUsed<6508332>, SimGasUsed<16281459:51168>, InvalidTxs<0>, lastRun<24ms>, RunTx<ApplyBlock<432ms>, abci<0ms>, persist<431ms>>, Prerun<1>, MempoolTxs<1>, Workload<0.05|0.05|0.04|0.05>, persistDetails<preChange<221ms>, flushCache<201ms>, commitStores<7ms>, flushMeta<0ms>>, Iavl[getnode<43702>, rdb<8494>, rdbTs<3535ms>, savenode<0>], DeliverTxs[RunAnte<0ms>, RunMsg<20ms>, refund<0ms>], Round[0], CommitRound[-1], Produce[Consensus<3800ms>, enterPropose-0-n-32409e<198ms>, recvProposal<0ms>, 1stPart<0ms>, lastPart<0ms>, Prevote-0<117ms>, Precommit-0<100ms>, Commit-0-0<5ms>, RunTx-0<433ms>, Waiting<2945ms>]. module=main ","receiveTime":"1672126881","packId":"6AEF88BF751EAECB-1CF04C","total":"2","logPath":"/data/logs/okexchaind.log","host":"10.13.1.184","topic":"","time":"2022-12-27 15:41:18","serviceId":"dex-val-06-kr-squares","projectName":"online-chain-hk"},{"hostName":"a04_valchainnode_service_pro_v_tky","packMeta":"MXxNVFkzTVRNMk5qRTBOREEzTkRrME1UYzNNdz09fDF8MA","moduleName":"val","serverName":"aliyun2","content":"content:I[2022-12-27|07:41:14.749][1] <font color=\"red\">Height</font><16281457>, Tx<2>, SimTx<<font color=\"red\">16281458</font>:1>, BlockSize<5036>, BTInterval<3893ms>, LastBlockTime<3800ms>, GasUsed<411144>, SimGasUsed<<font color=\"red\">16281458</font>:6508332>, InvalidTxs<0>, lastRun<7ms>, RunTx<ApplyBlock<18ms>, abci<0ms>, persist<17ms>>, Prerun<1>, MempoolTxs<1>, Workload<0.05|0.05|0.04|0.05>, persistDetails<preChange<13ms>, flushCache<2ms>, commitStores<1ms>, flushMeta<0ms>>, Iavl[getnode<2252>, rdb<103>, rdbTs<40ms>, savenode<0>], DeliverTxs[RunAnte<0ms>, RunMsg<2ms>, refund<0ms>], Round[0], CommitRound[-1], Produce[Consensus<3800ms>, enterPropose-0-n-c12ba4<161ms>, recvProposal<0ms>, 1stPart<0ms>, lastPart<0ms>, Prevote-0<171ms>, Precommit-0<109ms>, Commit-0-0<5ms>, RunTx-0<18ms>, Waiting<3333ms>]. module=main ","receiveTime":"1672126877","packId":"6AEF88BF751EAECB-1CF04B","total":"2","logPath":"/data/logs/okexchaind.log","host":"10.13.1.184","topic":"","time":"2022-12-27 15:41:14","serviceId":"dex-val-06-kr-squares","projectName":"online-chain-hk"}],"total":2,"item":null}}
文本处理:
jq .data.rows | jq '.[] | .content' | sed 's/>/>/g' | sed 's/</</g' | sed 's/<font color=\\"red\\">//g' | sed 's/<\/font>//g' | grep 'Height<16281458>' > 2022-12-27.log重点1:字体红色的red要两个反斜线。
重点2:增加grep Height,筛掉不符合条件的那一行
sed:
https://blog.csdn.net/junjieguo/article/details/7525794
jq:
https://wangchujiang.com/linux-command/c/jq.html
https://mozillazg.com/2018/01/jq-use-examples-cookbook.html
https://tallate.github.io/226416.html
标签:gt,0ms,jq,0.05,lt,27,日志,筛选 From: https://www.cnblogs.com/zccst/p/17008727.html