Skip to content

Commit 3283181

Browse files
authored
fix(stdlib): Fix parsing nginx error log delaying request (#1285)
1 parent 16966ee commit 3283181

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

changelog.d/1285.fix.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
The `parse_nginx_log` function can now parse `delaying requests` error messages.
2+
3+
authors: JakubOnderka

src/stdlib/log_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub(crate) static REGEX_NGINX_ERROR_LOG: LazyLock<Regex> = LazyLock::new(|| {
183183
(?P<tid>\d+): # Match any number
184184
(\s+\*(?P<cid>\d+))? # Match any number
185185
\s+(?P<message>.+?) # Match any character
186-
(,\s+excess:\s+(?P<excess>[^\s]+)\sby\szone\s"(?P<zone>[^,]+)")? # Match any character after ', excess: ' until ' by zone ' and the rest of characters
186+
(,\s+excess:\s+(?P<excess>[^\s,]+),?\sby\szone\s"(?P<zone>[^,]+)")? # Match any character after ', excess: ' until ' by zone ' and the rest of characters
187187
(,\s+client:\s+(?P<client>[^,]+))? # Match any character after ', client: '
188188
(,\s+server:\s+(?P<server>[^,]*))? # Match any character after ', server: '
189189
(,\s+request:\s+"(?P<request>[^"]*)")? # Match any character after ', request: '

src/stdlib/parse_nginx_log.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,28 @@ mod tests {
669669
tdef: TypeDef::object(kind_error()).fallible(),
670670
}
671671

672+
error_rate_delaying {
673+
args: func_args![
674+
value: r#"2022/05/30 20:56:22 [error] 7164#7164: *38068741 delaying requests, excess: 50.416, by zone "api_access_token", client: 10.244.0.0, server: test.local, request: "GET / HTTP/2.0", host: "127.0.0.1:8080""#,
675+
format: "error"
676+
],
677+
want: Ok(btreemap! {
678+
"timestamp" => Value::Timestamp(DateTime::parse_from_rfc3339("2022-05-30T20:56:22Z").unwrap().into()),
679+
"severity" => "error",
680+
"pid" => 7164,
681+
"tid" => 7164,
682+
"cid" => 38_068_741,
683+
"message" => "delaying requests",
684+
"excess" => 50.416,
685+
"zone" => "api_access_token",
686+
"client" => "10.244.0.0",
687+
"server" => "test.local",
688+
"request" => "GET / HTTP/2.0",
689+
"host" => "127.0.0.1:8080",
690+
}),
691+
tdef: TypeDef::object(kind_error()).fallible(),
692+
}
693+
672694
error_message_with_comma {
673695
args: func_args![
674696
value: r#"2022/05/30 20:56:22 [info] 3134#0: *99247 epoll_wait() reported that client prematurely closed connection, so upstream connection is closed too (104: Connection reset by peer) while reading upstream, client: 10.244.0.0, server: example.org, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php8.3-fpm.sock:", host: "example:8080""#,

0 commit comments

Comments
 (0)