Improved Gitea probing.

This commit is contained in:
Christian P. MOMON 2022-02-18 19:39:47 +01:00
parent 0f9e3c4ae8
commit 066203eae1
4 changed files with 15 additions and 10 deletions

View file

@ -151,14 +151,16 @@ public class Prober
logger.info("== Probing Gitea.");
String httpLogs = configuration.getProbeHttpAccessLogSource();
logger.info("httpLogs=[{}]", httpLogs);
String httpAccessLogRegex = configuration.getProbeHttpAccessLogPattern();
logger.info("httpAccessPattern=[{}]", httpAccessLogRegex);
File dataDirectory = configuration.getAsFile("conf.probe.gitea.data");
logger.info("dataPath=[{}]", dataDirectory);
String apiURL = configuration.get("conf.probe.gitea.api.url");
logger.info("apiURL=[{}]", apiURL);
String apiToken = configuration.get("conf.probe.gitea.api.token");
logger.info("apiToken=[{}]", apiToken);
logger.info("apiToken=[{}]", apiToken == null ? "null" : "************************");
PathCounters metrics = GiteaProber.probe(FilesUtils.searchByWildcard(httpLogs), null, apiURL, apiToken, dataDirectory);
PathCounters metrics = GiteaProber.probe(FilesUtils.searchByWildcard(httpLogs), httpAccessLogRegex, apiURL, apiToken, dataDirectory);
counters.putAll(metrics);
}

View file

@ -65,7 +65,6 @@ public class GiteaAPI
//
json = IOUtils.toString(new URL(url + "/api/v1/repos/search?limit=100000&token=" + token), Charset.defaultCharset());
System.out.println(json);
this.repositories = (JSONArray) ((JSONObject) (new JSONParser().parse(json))).get("data");
}

View file

@ -82,11 +82,13 @@ public class GiteaProber
// metrics.service.files.count
result.putAll(DatafilesProber.probe(dataPath));
//
System.out.println("Probing GiteaAPI [" + apiURL + "]");
if (!StringUtils.isBlank(apiURL) && (!StringUtils.isBlank(apiToken)))
{
try
{
GiteaAPI gitea = new GiteaAPI("https://forge.devinsy.fr/", "6fd97c63c25cabf67ff90731ee79ab4568be89b0");
GiteaAPI gitea = new GiteaAPI(apiURL, apiToken);
// metrics.service.accounts
// metrics.service.accounts.active
@ -110,6 +112,12 @@ public class GiteaProber
result.set(gitea.getPrivateRepositoryCount(), "metrics.forge.repositories.private");
result.set(gitea.getForkRepositoryCount(), "metrics.forge.repositories.forks");
result.set(gitea.getMirrorRepositoryCount(), "metrics.forge.repositories.mirrors");
// metrics.issues.count.* =
// metrics.issues.issuers.*=
// metrics.issues.created.* =
// metrics.issues.closed.* =
}
catch (IOException | ParseException exception)
{
@ -273,7 +281,6 @@ public class GiteaProber
// metrics.service.users.ipv6
if ((!log.isBot()) && (USE_PATTERN.matcher(log.getRequest()).matches()))
{
System.out.println(log.toStringLog());
String key = String.format("%s---%s", log.getIp(), log.getUserAgent());
users.put(key, year, yearMonth, yearWeek, date);

View file

@ -24,7 +24,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.DatabaseConfig;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.metrics.PathCounters;
/**
@ -44,13 +43,11 @@ public class DatabaseProber
/**
* Probe.
*
* @param directory
* the directory
* @param config
* the config
* @return the path counters
* @throws IOException
* Signals that an I/O exception has occurred.
* @throws StatoolInfosException
* the statool infos exception
*/
public static PathCounters probe(final DatabaseConfig config) throws IOException
{