JSON模式
更新時間 2024-09-02 10:19:31
最近更新時間: 2024-09-02 10:19:31
分享文章
本文主要介紹結構化解析-JSON模式。
概述
支持解析Object類型的JSON日志,提取JSON日志內容作為Key-Value鍵值對,即Object首層的鍵作為Key,Object首層的值作為Value。
示例
如您需要采集的原始數據為:
- 原始日志:
{"time_local":"22/Jan/2019:19:19:34 +0800","body_sent":23,"responsetime":0.232,"upstreamtime":"0.232","http_host":"127.0.0.1","method":"POST","request":"POST","xff":"-","referer":"//www.daliqc.cn","agent":"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0","response_code":"200"} - 經過結構化處理后,采集到云日志服務后的日志如下:
agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0 body_sent: 23 http_host: 127.0.0.1 method: POST referer: //www.daliqc.cn request: POST response_code: 200 responsetime: 0.232 time_local: 12/Jan/2023:21:33:18 +0800 upstreamtime: 0.232 xff: - __message__: {"time_local":"22/Jan/2019:19:19:34 +0800","body_sent":23,"responsetime":0.232,"upstreamtime":"0.232","http_host":"127.0.0.1","method":"POST","request":"POST","xff":"-","referer":"//www.daliqc.cn","agent":"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:64.0) Gecko/20100101 Firefox/64.0","response_code":"200"}
配置說明
在日志接入流程中-創建采集配置步驟中,切割模式選擇JSON模式即可。
