Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 日志中多种格式的正则表达式问题_Regex_Fluent - Fatal编程技术网

Regex 日志中多种格式的正则表达式问题

Regex 日志中多种格式的正则表达式问题,regex,fluent,Regex,Fluent,我有一个apache日志,有两种不同的格式,并使用下面的td代理配置。 在这个配置中,只有一个日志匹配,另一个表示模式不匹配。 一些人能帮助调整这个正则表达式以匹配这两种情况吗 @type tail path /var/log/httpd/ssl_access_log pos_file /var/log/td-agent/var_log_httpd_ssl_access_log.pos read_from_head true tag /var

我有一个apache日志,有两种不同的格式,并使用下面的td代理配置。 在这个配置中,只有一个日志匹配,另一个表示模式不匹配。 一些人能帮助调整这个正则表达式以匹配这两种情况吗

@type tail
path           /var/log/httpd/ssl_access_log
pos_file       /var/log/td-agent/var_log_httpd_ssl_access_log.pos
read_from_head true
tag            /var/log/httpd/ssl_access_log
<parse>
  @type regexp
    expression  /^(?<client_ip>[^ ]*)((, [^ ]*)*)? (?<proxy_ip>[^ ]*) (?<ident>[^ ]*) (?<user>[^ ]*) (?<time>[^ ]*) "(?<method>\S+)(?: +(?<path>[^ ]*) (?<protocol>[A-Z]{1,}[^ ]*)+\S*)?" (?<code>[^ ]*) (?<size>[^ ]*) (?<duration>[^ ]*) (?<received>[^ ]*) (?<sent>[^ ]*)(?: "(?<referer>[^\"]*)?" "(?<user_agent>[^\"]*)?")?(?: (?<userid>[^ ]*))?/
    time_format %Y-%m-%dT%H:%M:%S.%L%Z
</parse>
@类型尾部
路径/var/log/httpd/ssl\u访问\u日志
pos\u文件/var/log/td-agent/var\u-log\u-httpd\u-ssl\u-access\u-log.pos
从你的头上读出来是真的
tag/var/log/httpd/ssl\u访问\u日志
@类型regexp
表达式/^(?[^]*)((,[^]*)*)?(?[^]*)(?[^]*)(?[^]*)(?[^]*)”(?\S+(?[^]*)(?[A-Z]{1,}[^]*)+\S*)(?
[^]*)(?[^]*)(?[^]*)(?[^]*)(?:((?:(?[^\”)((?:(?[^\)*)((?:(?[^\))*)((?:(?:)((?:(?[^\))*)((?)/
时间\u格式%Y-%m-%dT%H:%m:%S.%L%Z

10.40.2.100--2020-03-02T14:18:06.688+0000“-”408-18423 137
(模式不匹配)

156.99.165.40,10.40.2.100 10.40.2.100--2020-03-02T14:18:06.710+0000“GET/api HTTP/1.1”500 336 1769 1431 725https://app.tl.com/login“Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/80.0.3987.116 Safari/537.36”
-(工作正常)

谢谢,
Kumar

您能否清楚地说明您的样本输入和期望输出是什么?此外,日志可以包含哪些内容?您希望匹配哪些内容?2种不同的格式是什么?请讲清楚。