metrics fixes
This commit is contained in:
parent
4408e7afda
commit
6b6fb88d75
|
@ -58,63 +58,235 @@ public class MetricsServiceImpl implements MetricsService {
|
|||
try {
|
||||
this.entityManager.disableTenantFilters();
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP, this.calculateDraftDmps(false), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP, this.calculateFinalizedDmps(false), MetricLabels.FINALIZED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP, this.calculatePublishedDmps(false), MetricLabels.PUBLISHED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP, this.calculateDoiedDmps(false), MetricLabels.DOIED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP, this.calculateDraftDmps(true), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP, this.calculateFinalizedDmps(true), MetricLabels.FINALIZED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP, this.calculatePublishedDmps(true), MetricLabels.PUBLISHED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP, this.calculateDoiedDmps(true), MetricLabels.DOIED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP_WITH_GRANT, this.calculateDraftDmpsWithGrant(false), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP_WITH_GRANT, this.calculateFinalizedDmpsWithGrant(false), MetricLabels.FINALIZED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP_WITH_GRANT, this.calculatePublishedDmpsWithGrant(false), MetricLabels.PUBLISHED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DMP_WITH_GRANT, this.calculateDoiedDmpsWithGrant(false), MetricLabels.DOIED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP_WITH_GRANT, this.calculateDraftDmpsWithGrant(true), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP_WITH_GRANT, this.calculateFinalizedDmpsWithGrant(true), MetricLabels.FINALIZED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP_WITH_GRANT, this.calculatePublishedDmpsWithGrant(true), MetricLabels.PUBLISHED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DMP_WITH_GRANT, this.calculateDoiedDmpsWithGrant(true), MetricLabels.DOIED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.FUNDERS, this.calculateAllFunders(false), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.GRANTS, this.calculateAllGrants(false), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.PROJECTS, this.calculateAllProjects(false), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.RESEARCHERS, this.calculateAllResearchers(false), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.FUNDERS, this.calculateAllFunders(true), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.GRANTS, this.calculateAllGrants(true), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.PROJECTS, this.calculateAllProjects(true), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.RESEARCHERS, this.calculateAllResearchers(true), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET, this.calculateDraftDatasets(false), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET, this.calculateFinalizedDatasets(false), MetricLabels.FINALIZED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET, this.calculatePublishedDatasets(false), MetricLabels.PUBLISHED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET, this.calculateDoiedDatasets(false), MetricLabels.DOIED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET, this.calculateDraftDatasets(true), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET, this.calculateFinalizedDatasets(true), MetricLabels.FINALIZED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET, this.calculatePublishedDatasets(true), MetricLabels.PUBLISHED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET, this.calculateDoiedDatasets(true), MetricLabels.DOIED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET_TEMPLATE, this.calculateDraftTemplates(false), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET_TEMPLATE, this.calculateFinalizedTemplates(false), MetricLabels.ACTIVE);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.DATASET_TEMPLATE, this.calculateUsedTemplates(false), MetricLabels.USED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET_TEMPLATE, this.calculateDraftTemplates(true), MetricLabels.DRAFT);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET_TEMPLATE, this.calculateFinalizedTemplates(true), MetricLabels.ACTIVE);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.DATASET_TEMPLATE, this.calculateUsedTemplates(true), MetricLabels.USED);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.LANGUAGES, this.calculateLanguages(), null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.INSTALLATIONS, 1d, null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.NEXUS_PREFIX + MetricNames.INSTALLATIONS, 1d, null);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.USERS, this.calculateActiveUsers(), MetricLabels.LOGGEDIN);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
try {
|
||||
this.setGaugeValue(gauges, MetricNames.USERS, this.calculateAllUsers(), MetricLabels.TOTAL);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} finally {
|
||||
this.entityManager.enableTenantFilters();
|
||||
}
|
||||
|
@ -317,13 +489,7 @@ public class MetricsServiceImpl implements MetricsService {
|
|||
}
|
||||
|
||||
private double calculateActiveUsers() {
|
||||
double result = -1;
|
||||
try {
|
||||
result = this.keycloakAdminRestApi.users().getUserSessionsCountByClientId(this._config.getUsersLoginClient());
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
return this.keycloakAdminRestApi.users().getUserSessionsCountByClientId(this._config.getUsersLoginClient());
|
||||
}
|
||||
|
||||
private double calculateAllUsers() {
|
||||
|
|
|
@ -3,7 +3,6 @@ metrics:
|
|||
enable: true
|
||||
intervalSeconds: 600
|
||||
nexusDate: "2021-01-01T00:00:00.00Z"
|
||||
usersLoginClient: ${IDP_APIKEY_CLIENT_ID_UUID:}
|
||||
referenceTypes:
|
||||
funderIds: ["538928bb-c7c6-452e-b66d-08e539f5f082"]
|
||||
grantIds: ["5b9c284f-f041-4995-96cc-fad7ad13289c"]
|
||||
|
|
|
@ -3,7 +3,7 @@ metrics:
|
|||
enable: false
|
||||
intervalSeconds: null
|
||||
nexusDate: null
|
||||
usersLoginClient: null
|
||||
usersLoginClient: ${IDP_APIKEY_CLIENT_ID_UUID}
|
||||
referenceTypes:
|
||||
funderIds: []
|
||||
grantIds: []
|
||||
|
|
Loading…
Reference in New Issue