metrics fixes
This commit is contained in:
parent
4408e7afda
commit
6b6fb88d75
|
@ -58,63 +58,235 @@ public class MetricsServiceImpl implements MetricsService {
|
||||||
try {
|
try {
|
||||||
this.entityManager.disableTenantFilters();
|
this.entityManager.disableTenantFilters();
|
||||||
|
|
||||||
|
try {
|
||||||
this.setGaugeValue(gauges, MetricNames.DMP, this.calculateDraftDmps(false), MetricLabels.DRAFT);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
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);
|
this.setGaugeValue(gauges, MetricNames.LANGUAGES, this.calculateLanguages(), null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
this.setGaugeValue(gauges, MetricNames.INSTALLATIONS, 1d, null);
|
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);
|
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);
|
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);
|
this.setGaugeValue(gauges, MetricNames.USERS, this.calculateAllUsers(), MetricLabels.TOTAL);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
this.entityManager.enableTenantFilters();
|
this.entityManager.enableTenantFilters();
|
||||||
}
|
}
|
||||||
|
@ -317,13 +489,7 @@ public class MetricsServiceImpl implements MetricsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateActiveUsers() {
|
private double calculateActiveUsers() {
|
||||||
double result = -1;
|
return this.keycloakAdminRestApi.users().getUserSessionsCountByClientId(this._config.getUsersLoginClient());
|
||||||
try {
|
|
||||||
result = this.keycloakAdminRestApi.users().getUserSessionsCountByClientId(this._config.getUsersLoginClient());
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private double calculateAllUsers() {
|
private double calculateAllUsers() {
|
||||||
|
|
|
@ -3,7 +3,6 @@ metrics:
|
||||||
enable: true
|
enable: true
|
||||||
intervalSeconds: 600
|
intervalSeconds: 600
|
||||||
nexusDate: "2021-01-01T00:00:00.00Z"
|
nexusDate: "2021-01-01T00:00:00.00Z"
|
||||||
usersLoginClient: ${IDP_APIKEY_CLIENT_ID_UUID:}
|
|
||||||
referenceTypes:
|
referenceTypes:
|
||||||
funderIds: ["538928bb-c7c6-452e-b66d-08e539f5f082"]
|
funderIds: ["538928bb-c7c6-452e-b66d-08e539f5f082"]
|
||||||
grantIds: ["5b9c284f-f041-4995-96cc-fad7ad13289c"]
|
grantIds: ["5b9c284f-f041-4995-96cc-fad7ad13289c"]
|
||||||
|
|
|
@ -3,7 +3,7 @@ metrics:
|
||||||
enable: false
|
enable: false
|
||||||
intervalSeconds: null
|
intervalSeconds: null
|
||||||
nexusDate: null
|
nexusDate: null
|
||||||
usersLoginClient: null
|
usersLoginClient: ${IDP_APIKEY_CLIENT_ID_UUID}
|
||||||
referenceTypes:
|
referenceTypes:
|
||||||
funderIds: []
|
funderIds: []
|
||||||
grantIds: []
|
grantIds: []
|
||||||
|
|
Loading…
Reference in New Issue