diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java index 39131b9e51..da64382420 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxProperties.java @@ -67,6 +67,11 @@ public class InfluxProperties extends StepRegistryProperties { */ private Boolean compressed; + /** + * Check if Influx database exists before attempting to publish metrics to it, creating it if it does not exist. + */ + private Boolean autoCreateDb; + public String getDb() { return this.db; } @@ -123,4 +128,11 @@ public class InfluxProperties extends StepRegistryProperties { this.compressed = compressed; } + public Boolean getAutoCreateDb() { + return this.autoCreateDb; + } + + public void setAutoCreateDb(Boolean autoCreateDb) { + this.autoCreateDb = autoCreateDb; + } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java index 0036002a3d..47ca979244 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxPropertiesConfigAdapter.java @@ -70,4 +70,8 @@ class InfluxPropertiesConfigAdapter extends return get(InfluxProperties::getCompressed, InfluxConfig.super::compressed); } + @Override + public boolean autoCreateDb() { + return get(InfluxProperties::getAutoCreateDb, InfluxConfig.super::autoCreateDb); + } }