Expose Elastic's pipeline and indexDateSeparator properties
Closes gh-20852
This commit is contained in:
parent
f293f6ad9b
commit
f64f5a0f55
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue