From cdbdc1cb7f798ad1674430269d30a21e712adfc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Sun, 26 Nov 2017 15:14:40 -0500 Subject: [PATCH 1/2] Add InfluxDb health indicator See gh-11159 --- .../pom.xml | 5 ++ ...luxDbHealthIndicatorAutoConfiguration.java | 64 ++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + ...HealthIndicatorAutoConfigurationTests.java | 73 +++++++++++++++++++ .../spring-boot-actuator/pom.xml | 5 ++ .../infux/InfluxDbHealthIndicator.java | 47 ++++++++++++ .../influx/InfluxDbHealthIndicatorTests.java | 64 ++++++++++++++++ 7 files changed, 259 insertions(+) create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java create mode 100644 spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java create mode 100644 spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/pom.xml b/spring-boot-project/spring-boot-actuator-autoconfigure/pom.xml index b54f924ec25..684b5f2307f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/pom.xml +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/pom.xml @@ -213,6 +213,11 @@ hibernate-validator true + + org.influxdb + influxdb-java + true + org.jolokia jolokia-core diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java new file mode 100644 index 00000000000..445eec44912 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.influx; + +import java.util.Map; + +import org.influxdb.InfluxDB; + +import org.springframework.boot.actuate.autoconfigure.health.CompositeHealthIndicatorConfiguration; +import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator; +import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; +import org.springframework.boot.actuate.health.HealthIndicator; +import org.springframework.boot.actuate.infux.InfluxDbHealthIndicator; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.influx.InfluxDbAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * {@link EnableAutoConfiguration Auto-configuration} for {@link InfluxDbHealthIndicator}. + * + * @author Eddú Meléndez + * @since 2.0.0 + */ +@Configuration +@ConditionalOnClass(InfluxDB.class) +@ConditionalOnBean(InfluxDB.class) +@ConditionalOnEnabledHealthIndicator("influxdb") +@AutoConfigureBefore(HealthIndicatorAutoConfiguration.class) +@AutoConfigureAfter(InfluxDbAutoConfiguration.class) +public class InfluxDbHealthIndicatorAutoConfiguration extends + CompositeHealthIndicatorConfiguration { + + private final Map influxDbs; + + public InfluxDbHealthIndicatorAutoConfiguration(Map influxDbs) { + this.influxDbs = influxDbs; + } + + @Bean + @ConditionalOnMissingBean(name = "influxdbHealthIndicator") + public HealthIndicator influxdbHealthIndicator() { + return createHealthIndicator(this.influxDbs); + } +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories index 8b1df5fca67..dc0d4189a21 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/spring.factories @@ -19,6 +19,7 @@ org.springframework.boot.actuate.autoconfigure.env.EnvironmentEndpointAutoConfig org.springframework.boot.actuate.autoconfigure.flyway.FlywayEndpointAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration,\ +org.springframework.boot.actuate.autoconfigure.influx.InfluxDbHealthIndicatorAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.info.InfoContributorAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration,\ org.springframework.boot.actuate.autoconfigure.jdbc.DataSourceHealthIndicatorAutoConfiguration,\ diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java new file mode 100644 index 00000000000..19c2884700e --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java @@ -0,0 +1,73 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.autoconfigure.influx; + +import org.influxdb.InfluxDB; +import org.junit.Test; + +import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAutoConfiguration; +import org.springframework.boot.actuate.health.ApplicationHealthIndicator; +import org.springframework.boot.actuate.infux.InfluxDbHealthIndicator; +import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +/** + * Tests for {@link InfluxDbHealthIndicatorAutoConfiguration}. + * + * @author Eddú Meléndez + */ +public class InfluxDbHealthIndicatorAutonConfigurationTests { + + private ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(InfluxDbConfiguration.class, + InfluxDbHealthIndicatorAutoConfiguration.class, + HealthIndicatorAutoConfiguration.class)); + + @Test + public void runShouldCreateIndicator() throws Exception { + this.contextRunner.run((context) -> assertThat(context) + .hasSingleBean(InfluxDbHealthIndicator.class) + .doesNotHaveBean(ApplicationHealthIndicator.class)); + } + + @Test + public void runWhenDisabledShouldNotCreateIndicator() throws Exception { + this.contextRunner + .withPropertyValues("management.health.influxdb.enabled:false").run( + (context) -> assertThat(context) + .doesNotHaveBean(InfluxDbHealthIndicator.class) + .hasSingleBean(ApplicationHealthIndicator.class)); + } + + @Configuration + @AutoConfigureBefore(InfluxDbHealthIndicatorAutoConfiguration.class) + protected static class InfluxDbConfiguration { + + @Bean + public InfluxDB influxdb() { + return mock(InfluxDB.class); + } + + } + +} diff --git a/spring-boot-project/spring-boot-actuator/pom.xml b/spring-boot-project/spring-boot-actuator/pom.xml index 2d08eefbb8e..301f5ed1915 100644 --- a/spring-boot-project/spring-boot-actuator/pom.xml +++ b/spring-boot-project/spring-boot-actuator/pom.xml @@ -101,6 +101,11 @@ infinispan-spring4-embedded true + + org.influxdb + influxdb-java + true + org.liquibase liquibase-core diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java new file mode 100644 index 00000000000..3e58c4c4054 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java @@ -0,0 +1,47 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.infux; + +import org.influxdb.InfluxDB; + +import org.springframework.boot.actuate.health.AbstractHealthIndicator; +import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.actuate.health.HealthIndicator; +import org.springframework.util.Assert; + +/** + * {@link HealthIndicator} for InfluxDb. + * + * @author Eddú Meléndez + * @since 2.0.0 + */ +public class InfluxDbHealthIndicator extends AbstractHealthIndicator { + + private final InfluxDB influxDb; + + public InfluxDbHealthIndicator(InfluxDB influxDb) { + Assert.notNull(influxDb, "InfluxDB must not be null"); + this.influxDb = influxDb; + } + + @Override + protected void doHealthCheck(Health.Builder builder) throws Exception { + String version = this.influxDb.version(); + builder.up().withDetail("version", version); + } + +} diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java new file mode 100644 index 00000000000..156b8a7a30f --- /dev/null +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java @@ -0,0 +1,64 @@ +/* + * Copyright 2012-2017 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.influx; + +import java.io.IOException; + +import org.influxdb.InfluxDB; +import org.influxdb.InfluxDBException; +import org.junit.Test; + +import org.springframework.boot.actuate.health.Health; +import org.springframework.boot.actuate.health.Status; +import org.springframework.boot.actuate.infux.InfluxDbHealthIndicator; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +/** + * Tests for {@link InfluxDbHealthIndicator} + * + * @author Eddú Meléndez + */ +public class InfluxDbHealthIndicatorTests { + + @Test + public void influxdbIsUp() { + InfluxDB influxDB = mock(InfluxDB.class); + given(influxDB.version()).willReturn("0.9"); + InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB); + Health health = healthIndicator.health(); + assertThat(health.getStatus()).isEqualTo(Status.UP); + assertThat(health.getDetails().get("version")).isEqualTo("0.9"); + verify(influxDB).version(); + } + + @Test + public void influxdbIsDown() { + InfluxDB influxDB = mock(InfluxDB.class); + given(influxDB.version()).willThrow( + new InfluxDBException(new IOException("Connection failed"))); + InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB); + Health health = healthIndicator.health(); + assertThat(health.getStatus()).isEqualTo(Status.DOWN); + assertThat((String) health.getDetails().get("error")) + .contains("Connection failed"); + verify(influxDB).version(); + } +} From a33c3eec3f0242165f21d95826d8e58ea5078b0d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 14 Dec 2017 15:16:00 +0100 Subject: [PATCH 2/2] Polish "Add InfluxDb health indicator" Closes gh-11159 --- ...luxDbHealthIndicatorAutoConfiguration.java | 7 ++++--- ...itional-spring-configuration-metadata.json | 6 ++++++ ...HealthIndicatorAutoConfigurationTests.java | 21 +++++++++---------- .../infux/InfluxDbHealthIndicator.java | 7 ++++--- .../influx/InfluxDbHealthIndicatorTests.java | 16 ++++++++------ .../appendix-application-properties.adoc | 1 + .../asciidoc/production-ready-features.adoc | 3 +++ 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java index 445eec44912..d4f55274b2f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java @@ -37,7 +37,7 @@ import org.springframework.context.annotation.Configuration; /** * {@link EnableAutoConfiguration Auto-configuration} for {@link InfluxDbHealthIndicator}. - * + * * @author Eddú Meléndez * @since 2.0.0 */ @@ -57,8 +57,9 @@ public class InfluxDbHealthIndicatorAutoConfiguration extends } @Bean - @ConditionalOnMissingBean(name = "influxdbHealthIndicator") - public HealthIndicator influxdbHealthIndicator() { + @ConditionalOnMissingBean(name = "influxDbHealthIndicator") + public HealthIndicator influxDbHealthIndicator() { return createHealthIndicator(this.influxDbs); } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 6f45fcd902f..12486747f07 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -103,6 +103,12 @@ "description": "Whether to enable elasticsearch health check.", "defaultValue": true }, + { + "name": "management.influxdb.jms.enabled", + "type": "java.lang.Boolean", + "description": "Whether to enable InfluxDB health check.", + "defaultValue": true + }, { "name": "management.health.jms.enabled", "type": "java.lang.Boolean", diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java index 19c2884700e..743bc96d539 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfigurationTests.java @@ -23,7 +23,6 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthIndicatorAuto import org.springframework.boot.actuate.health.ApplicationHealthIndicator; import org.springframework.boot.actuate.infux.InfluxDbHealthIndicator; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -33,35 +32,35 @@ import static org.mockito.Mockito.mock; /** * Tests for {@link InfluxDbHealthIndicatorAutoConfiguration}. - * + * * @author Eddú Meléndez */ -public class InfluxDbHealthIndicatorAutonConfigurationTests { +public class InfluxDbHealthIndicatorAutoConfigurationTests { private ApplicationContextRunner contextRunner = new ApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(InfluxDbConfiguration.class, + .withUserConfiguration(InfluxDbConfiguration.class) + .withConfiguration(AutoConfigurations.of( InfluxDbHealthIndicatorAutoConfiguration.class, HealthIndicatorAutoConfiguration.class)); @Test - public void runShouldCreateIndicator() throws Exception { + public void runShouldCreateIndicator() { this.contextRunner.run((context) -> assertThat(context) .hasSingleBean(InfluxDbHealthIndicator.class) .doesNotHaveBean(ApplicationHealthIndicator.class)); } @Test - public void runWhenDisabledShouldNotCreateIndicator() throws Exception { + public void runWhenDisabledShouldNotCreateIndicator() { this.contextRunner .withPropertyValues("management.health.influxdb.enabled:false").run( - (context) -> assertThat(context) - .doesNotHaveBean(InfluxDbHealthIndicator.class) - .hasSingleBean(ApplicationHealthIndicator.class)); + (context) -> assertThat(context) + .doesNotHaveBean(InfluxDbHealthIndicator.class) + .hasSingleBean(ApplicationHealthIndicator.class)); } @Configuration - @AutoConfigureBefore(InfluxDbHealthIndicatorAutoConfiguration.class) - protected static class InfluxDbConfiguration { + static class InfluxDbConfiguration { @Bean public InfluxDB influxdb() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java index 3e58c4c4054..777219afd1a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/infux/InfluxDbHealthIndicator.java @@ -17,6 +17,7 @@ package org.springframework.boot.actuate.infux; import org.influxdb.InfluxDB; +import org.influxdb.dto.Pong; import org.springframework.boot.actuate.health.AbstractHealthIndicator; import org.springframework.boot.actuate.health.Health; @@ -39,9 +40,9 @@ public class InfluxDbHealthIndicator extends AbstractHealthIndicator { } @Override - protected void doHealthCheck(Health.Builder builder) throws Exception { - String version = this.influxDb.version(); - builder.up().withDetail("version", version); + protected void doHealthCheck(Health.Builder builder) { + Pong pong = this.influxDb.ping(); + builder.up().withDetail("version", pong.getVersion()); } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java index 156b8a7a30f..ff4a24d9680 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicatorTests.java @@ -20,6 +20,7 @@ import java.io.IOException; import org.influxdb.InfluxDB; import org.influxdb.InfluxDBException; +import org.influxdb.dto.Pong; import org.junit.Test; import org.springframework.boot.actuate.health.Health; @@ -39,26 +40,29 @@ import static org.mockito.Mockito.verify; public class InfluxDbHealthIndicatorTests { @Test - public void influxdbIsUp() { + public void influxDbIsUp() { + Pong pong = mock(Pong.class); + given(pong.getVersion()).willReturn("0.9"); InfluxDB influxDB = mock(InfluxDB.class); - given(influxDB.version()).willReturn("0.9"); + given(influxDB.ping()).willReturn(pong); InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.UP); assertThat(health.getDetails().get("version")).isEqualTo("0.9"); - verify(influxDB).version(); + verify(influxDB).ping(); } @Test - public void influxdbIsDown() { + public void influxDbIsDown() { InfluxDB influxDB = mock(InfluxDB.class); - given(influxDB.version()).willThrow( + given(influxDB.ping()).willThrow( new InfluxDBException(new IOException("Connection failed"))); InfluxDbHealthIndicator healthIndicator = new InfluxDbHealthIndicator(influxDB); Health health = healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat((String) health.getDetails().get("error")) .contains("Connection failed"); - verify(influxDB).version(); + verify(influxDB).ping(); } + } 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 3effa7411fd..a4449b56d65 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 @@ -1224,6 +1224,7 @@ content into your application. Rather, pick only the properties that you need. management.health.elasticsearch.indices= # Comma-separated index names. management.health.elasticsearch.response-timeout=100ms # The time to wait for a response from the cluster. management.health.jms.enabled=true # Whether to enable JMS health check. + management.health.influxdb.enabled=true # Whether to enable InfluxDB health check. management.health.ldap.enabled=true # Whether to enable LDAP health check. management.health.mail.enabled=true # Whether to enable Mail health check. management.health.mongo.enabled=true # Whether to enable MongoDB health check. diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index 7e630b2db67..a87a822c79e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -368,6 +368,9 @@ The following `HealthIndicators` are auto-configured by Spring Boot when appropr |{sc-spring-boot-actuator}/elasticsearch/ElasticsearchHealthIndicator.{sc-ext}[`ElasticsearchHealthIndicator`] |Checks that an Elasticsearch cluster is up. +|{sc-spring-boot-actuator}/influx/InfluxDbHealthIndicator.{sc-ext}[`InfluxDbHealthIndicator`] +|Checks that an InfluxDB server is up. + |{sc-spring-boot-actuator}/jms/JmsHealthIndicator.{sc-ext}[`JmsHealthIndicator`] |Checks that a JMS broker is up.