Added method http metric.
This commit is contained in:
parent
6bf8037cc5
commit
6850f3b57a
3 changed files with 102 additions and 1 deletions
|
@ -82,6 +82,36 @@ public class HttpAccessLog
|
||||||
return this.ip;
|
return this.ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the method.
|
||||||
|
*
|
||||||
|
* @return the method
|
||||||
|
*/
|
||||||
|
public HttpMethod getMethod()
|
||||||
|
{
|
||||||
|
HttpMethod result;
|
||||||
|
|
||||||
|
if (this.request == null)
|
||||||
|
{
|
||||||
|
result = HttpMethod.UNKNOWN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int space = this.request.indexOf(' ');
|
||||||
|
if (space == -1)
|
||||||
|
{
|
||||||
|
result = HttpMethod.UNKNOWN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = HttpMethod.of(this.request.substring(0, space));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public String getReferer()
|
public String getReferer()
|
||||||
{
|
{
|
||||||
return this.referer;
|
return this.referer;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
|
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
*
|
*
|
||||||
* This file is part of StatoolInfos, simple service statistics tool.
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
*
|
*
|
||||||
|
@ -344,6 +344,10 @@ public class HttpAccessLogAnalyzer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// metrics.http.methods.XXXX
|
||||||
|
String method = log.getMethod().toString();
|
||||||
|
this.counters.inc("metrics.http.methods." + method, year, yearMonth, yearWeek, date);
|
||||||
|
|
||||||
// metrics.http.status.XXXX
|
// 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);
|
||||||
|
|
67
src/fr/devinsy/statoolinfos/metrics/http/HttpMethod.java
Normal file
67
src/fr/devinsy/statoolinfos/metrics/http/HttpMethod.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 Christian Pierre MOMON <christian@momon.org>
|
||||||
|
*
|
||||||
|
* This file is part of StatoolInfos, simple service statistics tool.
|
||||||
|
*
|
||||||
|
* StatoolInfos is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* StatoolInfos is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package fr.devinsy.statoolinfos.metrics.http;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class HttpMethod.
|
||||||
|
*/
|
||||||
|
public enum HttpMethod
|
||||||
|
{
|
||||||
|
GET,
|
||||||
|
HEAD,
|
||||||
|
POST,
|
||||||
|
OPTIONS,
|
||||||
|
CONNECT,
|
||||||
|
TRACE,
|
||||||
|
PUT,
|
||||||
|
PATCH,
|
||||||
|
DELETE,
|
||||||
|
UNKNOWN;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* the value
|
||||||
|
* @return the http method
|
||||||
|
*/
|
||||||
|
public static HttpMethod of(final String value)
|
||||||
|
{
|
||||||
|
HttpMethod result;
|
||||||
|
|
||||||
|
if (value == null)
|
||||||
|
{
|
||||||
|
result = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = valueOf(value);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException exception)
|
||||||
|
{
|
||||||
|
result = UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue