Added some more metric to probe.

This commit is contained in:
Christian P. MOMON 2021-05-23 02:02:31 +02:00
parent 5ece10ea2a
commit fb4ff4483f

View file

@ -47,9 +47,13 @@ public class HttpAccessLogAnalyzer
private int errorCount;
private PathCounters counters;
private VisitCounters visits;
private VisitCounters botVisits;
private VisitCounters visitorVisits;
private IpCounters ips;
private IpCounters ipv4;
private IpCounters ipv6;
private IpCounters botIps;
private IpCounters visitorIps;
/**
* Instantiates a new http access log prober.
@ -58,9 +62,13 @@ public class HttpAccessLogAnalyzer
{
this.counters = new PathCounters();
this.visits = new VisitCounters();
this.botVisits = new VisitCounters();
this.visitorVisits = new VisitCounters();
this.ips = new IpCounters();
this.ipv4 = new IpCounters();
this.ipv6 = new IpCounters();
this.botIps = new IpCounters();
this.visitorIps = new IpCounters();
}
/**
@ -78,6 +86,7 @@ public class HttpAccessLogAnalyzer
result.putAll(this.ips.getCounters("metrics.http.ip"));
result.putAll(this.ipv4.getCounters("metrics.http.ip.ipv4"));
result.putAll(this.ipv6.getCounters("metrics.http.ip.ipv6"));
result.putAll(this.botIps.getCounters("metrics.http.ip.ipv6"));
result.putAll(this.visits.getCounters("metrics.http.visits"));
@ -156,7 +165,7 @@ public class HttpAccessLogAnalyzer
// metrics.http.files
if (log.getBodyBytesSent() != 0)
{
this.counters.inc("metrics.http.file", year, yearMonth, yearWeek, date);
this.counters.inc("metrics.http.files", year, yearMonth, yearWeek, date);
}
// metrics.http.bytes
@ -167,6 +176,22 @@ public class HttpAccessLogAnalyzer
{
this.counters.inc("metrics.http.hits.bots", year, yearMonth, yearWeek, date);
}
else
{
// metrics.http.hits.visitors.*
this.counters.inc("metrics.http.hits.visitors", year, yearMonth, yearWeek, date);
if (log.isIPv4())
{
// metrics.http.hits.visitors.ipv4.*
this.counters.inc("metrics.http.hits.visitors.ipv4", year, yearMonth, yearWeek, date);
}
else
{
// metrics.http.hits.visitors.ipv6.*
this.counters.inc("metrics.http.hits.visitors.ipv6", year, yearMonth, yearWeek, date);
}
}
// metrics.http.pages.* =
if ((isPage(log.getRequest())) && (log.getStatus().getCategory() == HttpStatusCategory.SUCCESS))
@ -191,9 +216,10 @@ public class HttpAccessLogAnalyzer
this.counters.inc("metrics.http.devices." + device.toString().toLowerCase(), year, yearMonth, yearWeek, date);
// metrics.http.ip.* =
this.ips.put(log.getRemoteAddress(), year, yearMonth, yearWeek, date);
// metrics.http.ip.ipv4.* =
// metrics.http.ip.ipv6.* =
this.ips.put(log.getRemoteAddress(), year, yearMonth, yearWeek, date);
if (log.isIPv4())
{
this.ipv4.put(log.getRemoteAddress(), year, yearMonth, yearWeek, date);
@ -203,8 +229,29 @@ public class HttpAccessLogAnalyzer
this.ipv6.put(log.getRemoteAddress(), year, yearMonth, yearWeek, date);
}
// metrics.http.ip.bots.*
// metrics.http.ip.visitors.*
if (log.isBot())
{
this.botIps.put(log.getRemoteAddress(), year, yearMonth, yearWeek, date);
}
else
{
this.visitorIps.put(log.getRemoteAddress(), year, yearMonth, yearWeek, date);
}
// metrics.http.visits.* =
this.visits.putVisit(log);
if (log.isBot())
{
this.botVisits.putVisit(log);
}
else
{
this.visitorVisits.putVisit(log);
}
this.visits.storeTimeMarks(year, yearMonth, yearWeek, date);
// metrics.http.countries.XX =