我正在提示如何最好地在oklog消息上过滤掉ULID。理想情况下,我希望直接从查询命令行执行此操作,而无需通过其他程序,但不要认为这是可能的吗?
鉴于此查询:
./ oklog query -from 1h
{" cluster_host_id":" awx", " level":" INFO"," @ timestamp":" 2018-04-07T21:19:43.362Z","主机&#34 ;: " awxweb"," logger_name":" awx.api.generics"," message":"用户管理员 退出。","输入":"其他"} 01CAH1XHTT8PMC1T98C2S00ZD2 {" cluster_host_id":" awx"," level":" INFO"," @ timestamp": " 2018-04-07T21:59:08.312Z"," host":" awxweb"," logger_name": " awx.api.generics"," message":"用户管理员登录。","输入": "其他"} 01CAH1XQN41EAR570FHGAPA34J ......
我无法在上面输入 jq ,例如
./ oklog query -from 1h | jq'。'
因为ULIDS
答案 0 :(得分:0)
仅供参考我这是我所做的;通过下面的Python运行oklog,然后jq可以正确显示json输出:
导入重新
stdin = sys.stdin.readline()。rstrip()
[print('{%s}'%j)for re in findall('{(。*?)}',stdin,re.S)]