Skip to content

Commit

Permalink
Move kibana reporting data stream settings into component template
Browse files Browse the repository at this point in the history
Previously these were contained in the index template, however, Kibana needs to be able to make
overrides to only the settings, so factoring these out would allow them to do this (in such a way
that they can be overridden by the `kibana-reporting@custom` component template as well).

Relates to elastic#97765
  • Loading branch information
dakrone committed Apr 17, 2024
1 parent eb6af0e commit 0e656ad
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
@@ -0,0 +1,14 @@
{
"template": {
"settings": {
"number_of_shards": 1,
"auto_expand_replicas": "0-1"
}
},
"_meta": {
"description": "default kibana reporting settings installed by elasticsearch",
"managed": true
},
"version": ${xpack.stack.template.version},
"deprecated": ${xpack.stack.template.deprecated}
}
Expand Up @@ -5,14 +5,10 @@
"hidden": true
},
"allow_auto_create": true,
"composed_of": ["kibana-reporting@custom"],
"composed_of": ["kibana-reporting@settings", "kibana-reporting@custom"],
"ignore_missing_component_templates": ["kibana-reporting@custom"],
"template": {
"lifecycle": {},
"settings": {
"number_of_shards": 1,
"auto_expand_replicas": "0-1"
},
"mappings": {
"properties": {
"meta": {
Expand Down
Expand Up @@ -47,7 +47,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry {

// The stack template registry version. This number must be incremented when we make changes
// to built-in templates.
public static final int REGISTRY_VERSION = 9;
public static final int REGISTRY_VERSION = 10;

public static final String TEMPLATE_VERSION_VARIABLE = "xpack.stack.template.version";
public static final Setting<Boolean> STACK_TEMPLATES_ENABLED = Setting.boolSetting(
Expand Down Expand Up @@ -107,6 +107,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry {
// Kibana reporting template
///////////////////////////////////
public static final String KIBANA_REPORTING_INDEX_TEMPLATE_NAME = ".kibana-reporting";
public static final String KIBANA_REPORTING_COMPONENT_TEMPLATE_NAME = "kibana-reporting@settings";

public StackTemplateRegistry(
Settings nodeSettings,
Expand Down Expand Up @@ -229,6 +230,13 @@ protected List<LifecyclePolicy> getLifecyclePolicies() {
REGISTRY_VERSION,
TEMPLATE_VERSION_VARIABLE,
ADDITIONAL_TEMPLATE_VARIABLES
),
new IndexTemplateConfig(
KIBANA_REPORTING_COMPONENT_TEMPLATE_NAME,
"/kibana-reporting@settings.json",
REGISTRY_VERSION,
TEMPLATE_VERSION_VARIABLE,
ADDITIONAL_TEMPLATE_VARIABLES
)
)) {
try {
Expand Down
Expand Up @@ -429,6 +429,7 @@ public void testSameOrHigherVersionTemplateNotUpgraded() {
versions.put(StackTemplateRegistry.METRICS_MAPPINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
versions.put(StackTemplateRegistry.SYNTHETICS_SETTINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
versions.put(StackTemplateRegistry.SYNTHETICS_MAPPINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
versions.put(StackTemplateRegistry.KIBANA_REPORTING_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
ClusterChangedEvent sameVersionEvent = createClusterChangedEvent(versions, nodes);
client.setVerifier((action, request, listener) -> {
if (action instanceof PutComponentTemplateAction) {
Expand Down Expand Up @@ -484,6 +485,10 @@ public void testSameOrHigherVersionTemplateNotUpgraded() {
StackTemplateRegistry.SYNTHETICS_MAPPINGS_COMPONENT_TEMPLATE_NAME,
StackTemplateRegistry.REGISTRY_VERSION + randomIntBetween(1, 1000)
);
versions.put(
StackTemplateRegistry.KIBANA_REPORTING_COMPONENT_TEMPLATE_NAME,
StackTemplateRegistry.REGISTRY_VERSION + randomIntBetween(1, 1000)
);
ClusterChangedEvent higherVersionEvent = createClusterChangedEvent(versions, nodes);
registry.clusterChanged(higherVersionEvent);
}
Expand Down

0 comments on commit 0e656ad

Please sign in to comment.