From 9b215df4e958872b0d47e2e2c7d74d832dcd3073 Mon Sep 17 00:00:00 2001 From: Jon Schneider Date: Tue, 6 Feb 2018 08:50:24 -0600 Subject: [PATCH 1/2] Add influx property to govern whether db is auto-created or not --- .../metrics/export/influx/InfluxProperties.java | 12 ++++++++++++ .../export/influx/InfluxPropertiesConfigAdapter.java | 4 ++++ 2 files changed, 16 insertions(+) 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); + } } From 63d2e944baf07c9f238ed6d4b8d27dad89275de9 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 7 Feb 2018 12:54:47 +0100 Subject: [PATCH 2/2] Polish "Add influx property to govern whether db is auto-created or not" Closes gh-11922 --- .../autoconfigure/metrics/export/influx/InfluxProperties.java | 3 ++- .../metrics/export/influx/InfluxPropertiesConfigAdapter.java | 1 + .../src/main/asciidoc/appendix-application-properties.adoc | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) 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 da64382420..f904b925e2 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 @@ -68,7 +68,8 @@ 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. + * Whether to create the Influx database if it does not exist before attempting to + * publish metrics to it. */ private Boolean 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 47ca979244..c86288582f 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 @@ -74,4 +74,5 @@ class InfluxPropertiesConfigAdapter extends public boolean autoCreateDb() { return get(InfluxProperties::getAutoCreateDb, InfluxConfig.super::autoCreateDb); } + } diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index e9b2f2c782..f089118908 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1340,6 +1340,7 @@ content into your application. Rather, pick only the properties that you need. management.metrics.export.graphite.rate-units= # Base time unit used to report rates. management.metrics.export.graphite.step= # Step size (i.e. reporting frequency) to use. management.metrics.export.graphite.tags-as-prefix= # For the default naming convention, turn the specified tag keys into part of the metric prefix. + management.metrics.export.influx.auto-create-db= # Whether to create the Influx database if it does not exist before attempting to publish metrics to it. management.metrics.export.influx.batch-size= # Number of measurements per request to use for the backend. If more measurements are found, then multiple requests will be made. management.metrics.export.influx.compressed= # Enable GZIP compression of metrics batches published to Influx. management.metrics.export.influx.connect-timeout= # Connection timeout for requests to the backend.