Added asset filter in http visit definition.

This commit is contained in:
Christian P. MOMON 2022-01-13 17:56:21 +01:00
parent f1361c9d25
commit 2e59500d69

View file

@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.metrics.http;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -35,6 +36,8 @@ public class HttpAccessLog
{ {
private static Logger logger = LoggerFactory.getLogger(HttpAccessLog.class); private static Logger logger = LoggerFactory.getLogger(HttpAccessLog.class);
public static final Pattern ASSET_PATTERN = Pattern.compile("^.*\\.(avi|css|gif|ico|jpeg|jpg|js|mp3|mp4|ogg|png|svg|wav) HTTP.*$");
private String ip; private String ip;
private String remoteUser; private String remoteUser;
private LocalDateTime time; private LocalDateTime time;
@ -240,7 +243,8 @@ public class HttpAccessLog
{ {
boolean result; boolean result;
if ((this.status.getCategory() == HttpStatusCategory.SUCCESS) && (!isBot()) && (this.request.startsWith("GET "))) if ((this.status.getCategory() == HttpStatusCategory.SUCCESS) && (!isBot()) && (this.request.startsWith("GET ")) &&
(!ASSET_PATTERN.matcher(this.request).matches()))
{ {
result = true; result = true;
} }