当我有默认设置时,我的日志是这样的:
2020-12-01T18:34:06+02:00 10.132.90.194 {"wfd_successful_hits_sec": "0", "sql_hits_sec_max": "0", "timestamp": "2020/12/01 18:34:01", "connection_sec_max": "1922", "http_hits_sec_max": "1106", "http_hits_sec": "106", "wfd_successful_hits_sec_max": "0", "sql_hits_sec": "0", "sql_audit_phase2_events_sec_max": "0", "hdfs_hits_sec": "0", "connection_sec": "26"}
但是一旦我尝试让它只写味精,它就会失败。
并给我剪掉开头的味精。
"0", "timestamp": "2020/12/01 18:34:01", "connection_sec_max": "1922", "http_hits_sec_max": "1106", "http_hits_sec": "106", "wfd_successful_hits_sec_max": "0", "sql_hits_sec": "0", "sql_audit_phase2_events_sec_max": "0", "hdfs_hits_sec": "0", "connection_sec": "26"}
我的 Rsyslog 配置:
$template OnlyMsg,"%msg:2:2048%\n"
$template CustomLog,"/logs/host-%fromhost%-%$year%-%$month%.log"
local5.* ?CustomLog;OnlyMsg
输入行对于 syslog 并没有真正标准化,因此例如字符串
{"wfd_successful_hits_sec":
可能被误认为是标签,而 msg 字段在此之后。您可能可以简单地使用该
rawmsg
属性而不是msg
,因为它包含整个输入行(在优先级之后)。尝试使用大约 40 个字符的起始偏移量来说明时间戳和 IP 地址。如果您有不同长度的 ip 地址,则可以使用正则表达式来匹配开始。