regex - 如何在正则表达式语句中找到 [**],以便我可以将 multi_line_start_pattern 用于 aws cloudwatch 代理
问题描述
我有一个看起来像这样的日志流:
[**] [1:10000001:1] ICMP test [**]
[Priority: 0]
12/12-05:35:39.933931 172.31.12.xxx -> 172.31.2.xxx
ICMP TTL:64 TOS:0x0 ID:375 IpLen:20 DgmLen:84 DF
Type:8 Code:0 ID:14832 Seq:3927 ECHO
[**] [1:10000001:1] ICMP test [**]
[Priority: 0]
12/12-05:35:40.933854 172.31.12.106 -> 172.31.2.207
ICMP TTL:64 TOS:0x0 ID:417 IpLen:20 DgmLen:84 DF
Type:8 Code:0 ID:14832 Seq:3928 ECHO
我想使用 cloudwatch 代理从多行事件创建单个事件。
根据文档:
multi_line_start_pattern – Specifies the pattern for identifying the start of a log message. A log message is made of a line that matches the pattern and any following lines that don't match the pattern.
If you omit this field, multi-line mode is disabled, and any line that begins with a non-whitespace character closes the previous log message and starts a new log message.
如何创建一个正则表达式来查找 [**] 是否存在。例如
"multi_line_start_pattern": "\\[\\*\\*\\]\\"
对于模式:
[**] ANYTHING [**]
根据我的收集,找到 [**] 的存在就足以找到多行事件的开始。
那么查找 [ ] 或更好的 [ ] ANYTHING [**] 的正则表达式模式是什么?我不知道正则表达式
谢谢
解决方案
试试这个,虽然它可能会因您的语言而异。
\[\*\*\].+
推荐阅读
- macos - 即使在启用远程自动化并且节点已连接到集线器后,Safari 也不会在 mac book pro 中启动
- mysql - 更新或插入 mysql
- c# - 样式属性和值
- flutter - 从 webview URL 导航到 InApp 屏幕
- niagara-4 - 如何使用 niagara 控制台在不同的端口启动 niagara 站?
- c++ - 如何正确初始化 Singleton 类实例并使用其变量?
- java - selenium jar 文件在项目构建路径中显示为缺失
- python - 无法安装自定义 python 模块
- javascript - 如何设置HighCharts的x轴摄入DateRange
- flutter - 如何在 Flutter 上的 boxfit 后在屏幕上获得真实的图像大小