logging - Cloudwatch 日志配置:timestamp_format 匹配
问题描述
我错过了AWS 文档中描述如何在给定行内评估 timestamp_format 的部分。
这里我有一个示例日志行:
[4138] 2021/07/19 15:20:57.996872 [INF] Listening for client connections on ...
如您所见,日期时间信息位于第二列。Cloudwatch 是否会自动匹配整行中配置的 timestamp_format 模式,还是始终假定 datetime 列需要位于第一列?我如何告诉 Cloudwatch 代理使用第二列进行timestamp_format
匹配?
解决方案
根据经验,它会找到第一个匹配的时间戳timestamp_format
。从我读过的文档来看,有点模棱两可。文档中有两个声明似乎证实了这一说法。
在timestamp_format
项目符号下有声明:
If a single log entry contains two time stamps that match the format, the first time stamp is used.
这表明它正在查看整个日志条目以查找匹配项,而不仅仅是解析第一个日期字段。
在multi_line_start_pattern
项目符号下有声明:
If you include this field, you can specify {timestamp_format} to use the same regular expression as your timestamp format. Otherwise, you can specify a different regular expression for CloudWatch Logs to use to determine the start lines of multi-line entries.
这表明我再次timestamp_format
习惯于在整个日志条目中进行模式匹配。
推荐阅读
- node.js - Jitsi Iframe API - “不幸的是,出了点问题”
- autodesk-forge - 自定义按钮图标 Autodesk Forge 查看器
- zip - ZipFile API 在打开文件时抛出错误
- java - 从给定的字符串数组创建多个数组
- c# - 意外的 String.Compare() 导致 .NET 5
- c++ - 在 C++ 中使用模板传递具有 N 个元素的数组
- python - 为什么所有的测试用例都没有通过?回文程序
- javascript - 如何“强制”Rails 读取 JS 文件,以便函数可用?
- poloniex - Poloniex websocket API 不断断开连接
- angular - Angular httpClient 无法读取未定义的属性未定义