diff --git a/pom.xml b/pom.xml index 11b7fe7c3..f086ab06f 100644 --- a/pom.xml +++ b/pom.xml @@ -191,11 +191,6 @@ io.micrometer micrometer-registry-prometheus - - com.github.oshi - oshi-core - 6.6.6 - org.springframework.boot spring-boot-starter-jdbc diff --git a/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java b/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java index 16aa8b1df..8db6d5a21 100644 --- a/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java +++ b/src/main/java/org/patinanetwork/codebloom/utilities/SystemMetricsConfig.java @@ -7,18 +7,21 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import oshi.SystemInfo; -import oshi.hardware.GlobalMemory; +/** + * Configuration for system metrics exposed to Prometheus through Spring Actuator. + * Prometheus ingests the metrics from Actuator through a Kubernetes object defined in the k8s-manifest. + * + * @see Service Monitor + */ @Configuration @EnableConfigurationProperties(CommitShaProperties.class) public class SystemMetricsConfig { - @Bean - public SystemInfo systemInfo() { - return new SystemInfo(); - } + /** + * Add commit sha to metrics so that the deployed version of the code being run on the instance is known. + */ @Bean public MeterBinder applicationInfoMetrics(CommitShaProperties commitShaProperties) { return registry -> { @@ -26,18 +29,4 @@ public MeterBinder applicationInfoMetrics(CommitShaProperties commitShaPropertie registry.gauge("application.info", tags, 1, n -> 1.0); }; } - - @Bean - public MeterBinder systemMemoryMetrics(SystemInfo systemInfo) { - return registry -> { - GlobalMemory memory = systemInfo.getHardware().getMemory(); - registry.gauge("system.info.memory.total", memory, GlobalMemory::getTotal); - registry.gauge("system.info.memory.available", memory, GlobalMemory::getAvailable); - registry.gauge("system.info.memory.used", memory, m -> m.getTotal() - m.getAvailable()); - registry.gauge( - "system.info.memory.usage", - memory, - m -> (double) (m.getTotal() - m.getAvailable()) / m.getTotal() * 100); - }; - } }