Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/1285.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The `parse_nginx_log` function can now parse `delaying requests` error messages.

authors: JakubOnderka
2 changes: 1 addition & 1 deletion src/stdlib/log_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub(crate) static REGEX_NGINX_ERROR_LOG: LazyLock<Regex> = LazyLock::new(|| {
(?P<tid>\d+): # Match any number
(\s+\*(?P<cid>\d+))? # Match any number
\s+(?P<message>.+?) # Match any character
(,\s+excess:\s+(?P<excess>[^\s]+)\sby\szone\s"(?P<zone>[^,]+)")? # Match any character after ', excess: ' until ' by zone ' and the rest of characters
(,\s+excess:\s+(?P<excess>[^\s,]+),?\sby\szone\s"(?P<zone>[^,]+)")? # Match any character after ', excess: ' until ' by zone ' and the rest of characters
(,\s+client:\s+(?P<client>[^,]+))? # Match any character after ', client: '
(,\s+server:\s+(?P<server>[^,]*))? # Match any character after ', server: '
(,\s+request:\s+"(?P<request>[^"]*)")? # Match any character after ', request: '
Expand Down
22 changes: 22 additions & 0 deletions src/stdlib/parse_nginx_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,28 @@ mod tests {
tdef: TypeDef::object(kind_error()).fallible(),
}

error_rate_delaying {
args: func_args![
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""#,
format: "error"
],
want: Ok(btreemap! {
"timestamp" => Value::Timestamp(DateTime::parse_from_rfc3339("2022-05-30T20:56:22Z").unwrap().into()),
"severity" => "error",
"pid" => 7164,
"tid" => 7164,
"cid" => 38_068_741,
"message" => "delaying requests",
"excess" => 50.416,
"zone" => "api_access_token",
"client" => "10.244.0.0",
"server" => "test.local",
"request" => "GET / HTTP/2.0",
"host" => "127.0.0.1:8080",
}),
tdef: TypeDef::object(kind_error()).fallible(),
}

error_message_with_comma {
args: func_args![
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""#,
Expand Down
Loading