问答详情
源自:3-9 sed高级操作命令-()符号使用

这种怎么提取request和x-request-id的组合

remote_addr=[172.17.5.152] http_x_forward=[-] time=[2023-04-29T16:25:12+08:00] request=[GET /api/sale/customer/manage/customer/status/in/shop/list?customer_id=16035228&shop_ids=566%2C423%2C76%2C-1%2C-1%2C466%2C46%2C423%2C466%2C44 HTTP/1.1] status=[200] byte=[293] elapsed=[0.249] refer=[-] body=[-] ua=[okhttp/3.6.0] cookie=[-] gzip=[-] log_id=[sale-customer-manage-v2-8579575566-mdz5j71682756712.371939-302232] msec=[1682756712.371] http_host=[sale-customer-manage.production.svc.renrenaiche.cn] http_accept=[*/*|gzip|-] upstream_response_time=[0.249] sent_http_set_cookie=[-] session_id=[-] rrc_tg=[-] x-request-id=[9b03de42-2291-9162-8588-46b706e2b88e]


提问者:北京_鲁班七号 2023-05-17 00:26

个回答

  • 北京_鲁班七号
    2023-05-17 00:33:52

    sed 's/remote_addr.*rtime=\([.*]\+\) request=\([.*]\+\) .*$/\1\2/' access.log 

    发现这么写不好使