Improved access log pattern.

This commit is contained in:
Christian P. MOMON 2021-02-24 14:56:32 +01:00
parent c2fd782860
commit 5e1f2d68d4

View file

@ -175,7 +175,7 @@ public class HttpAccessLogAnalyzer
this.counters.inc("metrics.http.pages", year, yearMonth, yearWeek, date); this.counters.inc("metrics.http.pages", year, yearMonth, yearWeek, date);
} }
// metrics.http.status.XXX // metrics.http.status.XXXX
String status = String.valueOf(log.getStatus().getCode()); String status = String.valueOf(log.getStatus().getCode());
this.counters.inc("metrics.http.status." + status, year, yearMonth, yearWeek, date); this.counters.inc("metrics.http.status." + status, year, yearMonth, yearWeek, date);
@ -262,7 +262,7 @@ public class HttpAccessLogAnalyzer
// log_format combined '$remote_addr - $remote_user [$time_local] ' // log_format combined '$remote_addr - $remote_user [$time_local] '
// '"$request" $status $body_bytes_sent ' // '"$request" $status $body_bytes_sent '
// '"$http_referer" "$http_user_agent"'; // '"$http_referer" "$http_user_agent"';
String combinedPattern = "^(?<remoteAddress>[a-zA-F0-9\\\\:\\\\.]+) - (?<remoteUser>\\S+) \\[(?<time>[^\\]]+)\\] \"(?<request>[^\"]*)\" (?<status>\\d+) (?<bodyBytesSent>\\d+) \"(?<referer>[^\"]*)\" \"(?<userAgent>[^\"]*)\".*$"; String combinedPattern = "^(?<remoteAddress>[a-zA-F0-9\\\\:\\\\.]+) - (?<remoteUser>[^\\[]+) \\[(?<time>[^\\]]+)\\] \"(?<request>[^\"]*)\" (?<status>\\d+) (?<bodyBytesSent>\\d+) \"(?<referer>[^\"]*)\" \"(?<userAgent>[^\"]*)\".*$";
Pattern pattern = Pattern.compile(combinedPattern); Pattern pattern = Pattern.compile(combinedPattern);