use of io.prometheus.client.Gauge in project verify-hub by alphagov.
the class PrometheusClient method createMatchingServiceHealthCheckMetrics.
public void createMatchingServiceHealthCheckMetrics() {
final PrometheusClientServiceConfiguration configuration = samlSoapProxyConfiguration.getMatchingServiceHealthCheckServiceConfiguration();
if (configuration.getEnable()) {
Gauge healthStatusGauge = Gauge.build(VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS, VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS_HELP).labelNames("matchingService").register();
Gauge healthStatusLastUpdatedGauge = Gauge.build(VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS_LAST_UPDATED, VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS_LAST_UPDATED_HELP).labelNames("matchingService").register();
MatchingServiceInfoMetric infoMetric = new MatchingServiceInfoMetric().register();
ExecutorService matchingServiceHealthCheckTaskManager = environment.lifecycle().executorService(MSA_HEALTH_CHECK_TASK_MANAGER).threadFactory(new ThreadFactoryBuilder().setNameFormat(MSA_HEALTH_CHECK_TASK_MANAGER).setDaemon(USE_DAEMON_THREADS).build()).minThreads(configuration.getMinNumOfThreads()).maxThreads(configuration.getMaxNumOfThreads()).keepAliveTime(configuration.getKeepAliveTime()).workQueue(new SynchronousQueue<>()).build();
MatchingServiceHealthCheckService matchingServiceHealthCheckService = new MatchingServiceHealthCheckService(matchingServiceHealthCheckTaskManager, samlSoapProxyConfiguration.getHealthCheckSoapHttpClient().getTimeout(), matchingServiceConfigProxy, matchingServiceHealthChecker, healthStatusGauge, healthStatusLastUpdatedGauge, infoMetric);
createScheduledExecutorService(configuration, VERIFY_SAML_SOAP_PROXY_MSA_HEALTH_STATUS, matchingServiceHealthCheckService);
}
}
use of io.prometheus.client.Gauge in project verify-hub by alphagov.
the class PrometheusClientService method createCertificateExpiryDateCheckMetrics.
public void createCertificateExpiryDateCheckMetrics() {
final PrometheusClientServiceConfiguration configuration = configConfiguration.getCertificateExpiryDateCheckServiceConfiguration();
if (configuration.getEnable()) {
Gauge expiryDateGauge = Gauge.build(VERIFY_CONFIG_CERTIFICATE_EXPIRY_DATE, VERIFY_CONFIG_CERTIFICATE_EXPIRY_DATE_HELP).labelNames("entity_id", "use", "subject", "fingerprint", "serial").register();
Gauge lastUpdatedGauge = Gauge.build(VERIFY_CONFIG_CERTIFICATE_EXPIRY_DATE_LAST_UPDATED, VERIFY_CONFIG_CERTIFICATE_EXPIRY_DATE_LAST_UPDATED_HELP).register();
CertificateExpiryDateCheckService certificateExpiryDateCheckService = new CertificateExpiryDateCheckService(certificateService, expiryDateGauge, lastUpdatedGauge);
createScheduledExecutorService(configuration, VERIFY_CONFIG_CERTIFICATE_EXPIRY_DATE, certificateExpiryDateCheckService);
}
}
use of io.prometheus.client.Gauge in project verify-hub by alphagov.
the class PrometheusClientService method createCertificateOcspRevocationStatusCheckMetrics.
public void createCertificateOcspRevocationStatusCheckMetrics() {
final PrometheusClientServiceConfiguration configuration = configConfiguration.getCertificateOcspRevocationStatusCheckServiceConfiguration();
if (configuration.getEnable()) {
Gauge ocspStatusGauge = Gauge.build(VERIFY_CONFIG_CERTIFICATE_OCSP_REVOCATION_STATUS, VERIFY_CONFIG_CERTIFICATE_OCSP_REVOCATION_STATUS_HELP).labelNames("entity_id", "use", "subject", "fingerprint", "serial").register();
Gauge lastUpdatedGauge = Gauge.build(VERIFY_CONFIG_CERTIFICATE_OCSP_LAST_SUCCESS_TIMESTAMP, VERIFY_CONFIG_CERTIFICATE_OCSP_LAST_SUCCESS_TIMESTAMP_HELP).labelNames("entity_id", "use", "subject", "fingerprint", "serial").register();
OcspCertificateChainValidationService ocspCertificateChainValidationService = new OcspCertificateChainValidationService(ocspCertificateChainValidityChecker, certificateService, ocspStatusGauge, lastUpdatedGauge);
createScheduledExecutorService(configuration, VERIFY_CONFIG_CERTIFICATE_OCSP_REVOCATION_STATUS, ocspCertificateChainValidationService);
}
}
use of io.prometheus.client.Gauge in project verify-hub by alphagov.
the class OcspCertificateChainValidationServiceTest method gaugesAreUpdatedForCertsWithValidChains.
@Test
public void gaugesAreUpdatedForCertsWithValidChains() throws Exception {
Gauge ocspStatusGauge = Gauge.build("ocspStatusGauge", "whatever").labelNames("entity_id", "use", "subject", "fingerprint", "serial").create();
Gauge lastUpdatedGauge = Gauge.build("lastUpdatedGauge", "whatever").labelNames("entity_id", "use", "subject", "fingerprint", "serial").create();
OcspCertificateChainValidationService ocspCertificateChainValidationService = new OcspCertificateChainValidationService(ocspCertificateChainValidityChecker, certificateService, ocspStatusGauge, lastUpdatedGauge);
// Check gauges are initially set to zero.
assertThat(getGaugeValue(ocspStatusGauge, cert1)).isEqualTo(0);
assertThat(getGaugeValue(ocspStatusGauge, cert2)).isEqualTo(0);
assertThat(getGaugeValue(ocspStatusGauge, cert3)).isEqualTo(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert1)).isEqualTo(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert2)).isEqualTo(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert3)).isEqualTo(0);
// Run the service and check gauges.
when(certificateService.getAllCertificates()).thenReturn(Set.of(cert1, cert2, cert3));
when(ocspCertificateChainValidityChecker.isValid(cert1)).thenReturn(true);
when(ocspCertificateChainValidityChecker.isValid(cert2)).thenReturn(true);
when(ocspCertificateChainValidityChecker.isValid(cert3)).thenReturn(false);
ocspCertificateChainValidationService.run();
assertThat(getGaugeValue(ocspStatusGauge, cert1)).isEqualTo(1);
assertThat(getGaugeValue(ocspStatusGauge, cert2)).isEqualTo(1);
assertThat(getGaugeValue(ocspStatusGauge, cert3)).isEqualTo(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert1)).isGreaterThan(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert2)).isGreaterThan(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert3)).isEqualTo(0);
// Make cert2 invalid and run the service again.
when(ocspCertificateChainValidityChecker.isValid(cert2)).thenReturn(false);
ocspCertificateChainValidationService.run();
assertThat(getGaugeValue(ocspStatusGauge, cert1)).isEqualTo(1);
assertThat(getGaugeValue(ocspStatusGauge, cert2)).isEqualTo(0);
assertThat(getGaugeValue(ocspStatusGauge, cert3)).isEqualTo(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert1)).isGreaterThan(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert2)).isGreaterThan(0);
assertThat(getGaugeValue(lastUpdatedGauge, cert3)).isEqualTo(0);
}
Aggregations