Improved page metric computation in probing.

This commit is contained in:
Christian P. MOMON 2021-05-22 01:11:04 +02:00
parent a2cbf2d762
commit 152af0d74a

View file

@ -169,7 +169,7 @@ public class HttpAccessLogAnalyzer
}
// metrics.http.pages.* =
if (StringUtils.endsWithAny(log.getRequest(), ".html", ".htm", ".xhtml", ".cgi", "/"))
if ((isPage(log.getRequest())) && (log.getStatus().getCategory() == HttpStatusCategory.SUCCESS))
{
this.counters.inc("metrics.http.pages", year, yearMonth, yearWeek, date);
}
@ -214,6 +214,45 @@ public class HttpAccessLogAnalyzer
}
}
/**
* Checks if is page.
*
* @param request
* the request
* @return true, if is page
*/
public static boolean isPage(final String request)
{
boolean result;
if (StringUtils.isBlank(request))
{
result = false;
}
else
{
Pattern PAGE_PATTERN = Pattern.compile("^.* (?<path>/[^ \\?]*)(\\?.*| .*)?$");
Matcher matcher = PAGE_PATTERN.matcher(request);
if (matcher.find())
{
String path = matcher.group("path").toLowerCase();
result = path.matches("^.*(/|/[^/]*\\.html|/[^/]*\\.htm|/[^/]*\\.xhtml|/[^/]*\\.cgi|/[^/]*\\.php|/[^/\\.]*[a-z0-9])$");
// System.out.println(result + " [" + path + "] [" + request +
// "]");
}
else
{
result = false;
}
}
//
return result;
}
/**
* Parses the log.
*