aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-monitoring
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-webserver-monitoring')
-rw-r--r--server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java4
-rw-r--r--server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java25
2 files changed, 23 insertions, 6 deletions
diff --git a/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java b/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java
index 82ed9dbd60a..db0afbd2a6a 100644
--- a/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java
+++ b/server/sonar-webserver-monitoring/src/main/java/org/sonar/server/monitoring/ServerMonitoringMetrics.java
@@ -79,12 +79,12 @@ public class ServerMonitoringMetrics {
.register();
computeEngineGauge = Gauge.build()
- .name("sonarqube_heath_compute_engine_status")
+ .name("sonarqube_health_compute_engine_status")
.help("Tells whether Compute Engine is up (healthy, ready to take tasks) or down. 1 for up, 0 for down")
.register();
elasticsearchGauge = Gauge.build()
- .name("sonarqube_heath_elasticsearch_status")
+ .name("sonarqube_health_elasticsearch_status")
.help("Tells whether Elasticsearch is up or down. 1 for Up, 0 for down")
.register();
diff --git a/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java b/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java
index 6d862b09dd1..3db9504b4f7 100644
--- a/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java
+++ b/server/sonar-webserver-monitoring/src/test/java/org/sonar/server/monitoring/ServerMonitoringMetricsTest.java
@@ -60,8 +60,8 @@ public class ServerMonitoringMetricsTest {
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_gitlab_status")).isPositive();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_bitbucket_status")).isPositive();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_azuredevops_status")).isPositive();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_compute_engine_status")).isPositive();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_elasticsearch_status")).isPositive();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_compute_engine_status")).isPositive();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_elasticsearch_status")).isPositive();
}
@Test
@@ -79,8 +79,8 @@ public class ServerMonitoringMetricsTest {
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_gitlab_status")).isZero();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_bitbucket_status")).isZero();
assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_integration_azuredevops_status")).isZero();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_compute_engine_status")).isZero();
- assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_heath_elasticsearch_status")).isZero();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_compute_engine_status")).isZero();
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_health_elasticsearch_status")).isZero();
}
@Test
@@ -120,6 +120,23 @@ public class ServerMonitoringMetricsTest {
}
@Test
+ public void setters_setElasticsearchMetricsWithLabels() {
+ ServerMonitoringMetrics metrics = new ServerMonitoringMetrics();
+ String[] labelNames = {"node_name"};
+ String[] labelValues = {"node_1"};
+
+ metrics.setElasticSearchDiskSpaceFreeBytes(labelValues[0], 30);
+ metrics.setElasticSearchDiskSpaceTotalBytes(labelValues[0], 30);
+
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_elasticsearch_disk_space_total_bytes",
+ labelNames, labelValues))
+ .isEqualTo(30);
+ assertThat(CollectorRegistry.defaultRegistry.getSampleValue("sonarqube_elasticsearch_disk_space_free_bytes",
+ labelNames, labelValues))
+ .isEqualTo(30);
+ }
+
+ @Test
public void observeComputeEngineTaskDurationTest() {
ServerMonitoringMetrics metrics = new ServerMonitoringMetrics();
String[] labelNames = {"task_type", "project_key"};