diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticProperties.java index 5af408d5d99..2a94556cda5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -40,11 +40,15 @@ public class ElasticProperties extends StepRegistryProperties { private String index = "metrics"; /** - * Index date format used for rolling indices. Appended to the index name, preceded by - * a '-'. + * Index date format used for rolling indices. Appended to the index name. */ private String indexDateFormat = "yyyy-MM"; + /** + * Prefix to separate the index name from the date format used for rolling indices. + */ + private String indexDateSeparator = "-"; + /** * Name of the timestamp field. */ @@ -65,6 +69,11 @@ public class ElasticProperties extends StepRegistryProperties { */ private String password = ""; + /** + * Ingest pipeline name. By default, events are not pre-processed. + */ + private String pipeline = ""; + public String getHost() { return this.host; } @@ -89,6 +98,14 @@ public class ElasticProperties extends StepRegistryProperties { this.indexDateFormat = indexDateFormat; } + public String getIndexDateSeparator() { + return this.indexDateSeparator; + } + + public void setIndexDateSeparator(String indexDateSeparator) { + this.indexDateSeparator = indexDateSeparator; + } + public String getTimestampFieldName() { return this.timestampFieldName; } @@ -121,4 +138,12 @@ public class ElasticProperties extends StepRegistryProperties { this.password = password; } + public String getPipeline() { + return this.pipeline; + } + + public void setPipeline(String pipeline) { + this.pipeline = pipeline; + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapter.java index 8d41ebe2523..06a507b506f 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -47,6 +47,11 @@ class ElasticPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter return get(ElasticProperties::getIndexDateFormat, ElasticConfig.super::indexDateFormat); } + @Override + public String indexDateSeparator() { + return get(ElasticProperties::getIndexDateSeparator, ElasticConfig.super::indexDateSeparator); + } + @Override public String timestampFieldName() { return get(ElasticProperties::getTimestampFieldName, ElasticConfig.super::timestampFieldName); @@ -67,4 +72,9 @@ class ElasticPropertiesConfigAdapter extends StepRegistryPropertiesConfigAdapter return get(ElasticProperties::getPassword, ElasticConfig.super::password); } + @Override + public String pipeline() { + return get(ElasticProperties::getPipeline, ElasticConfig.super::pipeline); + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapterTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapterTests.java index f3a27b724a3..23e840531c1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapterTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesConfigAdapterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -48,6 +48,13 @@ class ElasticPropertiesConfigAdapterTests { assertThat(new ElasticPropertiesConfigAdapter(properties).indexDateFormat()).isEqualTo("yyyy"); } + @Test + void whenPropertiesIndexDateSeparatorIsSetAdapterIndexDateFormatReturnsIt() { + ElasticProperties properties = new ElasticProperties(); + properties.setIndexDateSeparator("*"); + assertThat(new ElasticPropertiesConfigAdapter(properties).indexDateSeparator()).isEqualTo("*"); + } + @Test void whenPropertiesTimestampFieldNameIsSetAdapterTimestampFieldNameReturnsIt() { ElasticProperties properties = new ElasticProperties(); @@ -76,4 +83,11 @@ class ElasticPropertiesConfigAdapterTests { assertThat(new ElasticPropertiesConfigAdapter(properties).password()).isEqualTo("secret"); } + @Test + void whenPropertiesPipelineIsSetAdapterPasswordReturnsIt() { + ElasticProperties properties = new ElasticProperties(); + properties.setPipeline("testPipeline"); + assertThat(new ElasticPropertiesConfigAdapter(properties).pipeline()).isEqualTo("testPipeline"); + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesTests.java index 407c968c14f..7e692f0a7f0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/elastic/ElasticPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2020 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. @@ -38,10 +38,12 @@ class ElasticPropertiesTests extends StepRegistryPropertiesTests { assertThat(properties.getHost()).isEqualTo(config.host()); assertThat(properties.getIndex()).isEqualTo(config.index()); assertThat(properties.getIndexDateFormat()).isEqualTo(config.indexDateFormat()); + assertThat(properties.getIndexDateSeparator()).isEqualTo(config.indexDateSeparator()); assertThat(properties.getPassword()).isEqualTo(config.password()); assertThat(properties.getTimestampFieldName()).isEqualTo(config.timestampFieldName()); assertThat(properties.getUserName()).isEqualTo(config.userName()); assertThat(properties.isAutoCreateIndex()).isEqualTo(config.autoCreateIndex()); + assertThat(properties.getPipeline()).isEqualTo(config.pipeline()); } }