diff --git a/src/main/java/org/jenkinsci/plugins/prometheus/DiskUsageCollector.java b/src/main/java/org/jenkinsci/plugins/prometheus/DiskUsageCollector.java index ee8c70048..8236b391b 100644 --- a/src/main/java/org/jenkinsci/plugins/prometheus/DiskUsageCollector.java +++ b/src/main/java/org/jenkinsci/plugins/prometheus/DiskUsageCollector.java @@ -39,6 +39,7 @@ public List collect() { return Collections.emptyList(); } catch (final java.lang.NoClassDefFoundError e) { LOGGER.warn("Cannot collect disk usage data because plugin CloudBees Disk Usage Simple is not installed: {}", e.toString()); + LOGGER.info("You can remove this warning if you disable Collect Disk Usage in Prometheus Configuration."); return Collections.emptyList(); } } diff --git a/src/main/java/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration.java b/src/main/java/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration.java index 0bdbad596..a3be69b9e 100644 --- a/src/main/java/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration.java +++ b/src/main/java/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration.java @@ -52,6 +52,9 @@ public class PrometheusConfiguration extends GlobalConfiguration { private boolean appendStatusLabel = false; private boolean perBuildMetrics = false; + + private transient boolean collectDiskUsageEnvironmentVariableSet = false; + private String labeledBuildParameterNames = ""; private boolean collectDiskUsage = true; @@ -115,7 +118,7 @@ public void setDefaultNamespace(String path) { } @DataBoundSetter - public void setCollectDiskUsage(Boolean collectDiskUsage) { + public void setCollectDiskUsage(boolean collectDiskUsage) { this.collectDiskUsage = collectDiskUsage; } @@ -123,13 +126,18 @@ public void setCollectDiskUsageBasedOnEnvironmentVariableIfDefined() { try { final String envValue = System.getenv(COLLECT_DISK_USAGE); if (envValue != null) { - this.collectDiskUsage = getValidBooleanValueOrThrowException(envValue); + setCollectDiskUsage(getValidBooleanValueOrThrowException(envValue)); + collectDiskUsageEnvironmentVariableSet = true; } } catch (IllegalArgumentException e) { logger.warn("Unable to parse environment variable '{}'. Must either be 'true' or 'false'. Ignoring...", COLLECT_DISK_USAGE); } } + public boolean isCollectDiskUsageEnvironmentVariableSet() { + return collectDiskUsageEnvironmentVariableSet; + } + private boolean getValidBooleanValueOrThrowException(String value) throws IllegalArgumentException { if ("true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value)) { return Boolean.parseBoolean(value); diff --git a/src/main/resources/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration/config.jelly b/src/main/resources/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration/config.jelly index cd328e0e3..974671849 100644 --- a/src/main/resources/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/prometheus/config/PrometheusConfiguration/config.jelly @@ -47,7 +47,7 @@ - +