-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Change deprecation indexing to use a custom template #64417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d1ae1f3
3f54368
64f4d29
a2ecfe1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"phases": { | ||
"hot": { | ||
"actions": { | ||
"rollover": { | ||
"max_size": "50gb", | ||
"max_age": "30d" | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"template": { | ||
"mappings": { | ||
"dynamic_templates": [ | ||
{ | ||
"strings_as_keyword": { | ||
"mapping": { | ||
"ignore_above": 1024, | ||
"type": "keyword" | ||
}, | ||
"match_mapping_type": "string" | ||
} | ||
} | ||
], | ||
"date_detection": false, | ||
"properties": { | ||
"@timestamp": { | ||
"type": "date" | ||
}, | ||
"data_stream": { | ||
"properties": { | ||
"type": { | ||
"type": "constant_keyword", | ||
"value": "logs" | ||
}, | ||
"dataset": { | ||
"type": "constant_keyword" | ||
}, | ||
"namespace": { | ||
"type": "constant_keyword" | ||
} | ||
} | ||
}, | ||
"ecs": { | ||
"properties": { | ||
"version": { | ||
"ignore_above": 1024, | ||
"type": "keyword" | ||
} | ||
} | ||
}, | ||
"host": { | ||
"properties": { | ||
"ip": { | ||
"type": "ip" | ||
} | ||
} | ||
}, | ||
"message": { | ||
"type": "text" | ||
} | ||
} | ||
} | ||
}, | ||
"_meta": { | ||
"description": "default mappings for ES deprecation logs index template installed by x-pack", | ||
"managed": true | ||
}, | ||
"version": ${xpack.deprecation.indexing.template.version} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"template": { | ||
"settings": { | ||
"index": { | ||
"lifecycle": { | ||
"name": ".deprecation-indexing-ilm-policy" | ||
}, | ||
"codec": "best_compression", | ||
"query": { | ||
"default_field": ["message"] | ||
} | ||
} | ||
} | ||
}, | ||
"_meta": { | ||
"description": "default settings for ES deprecation logs index template installed by x-pack", | ||
"managed": true | ||
}, | ||
"version": ${xpack.deprecation.indexing.template.version} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"index_patterns": [".logs-deprecation-elasticsearch"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a breaking change now, since deprecation logging went into effect in 7.10, and we're changing the index name, are we sure we're okay with the breaking change in a minor release? I'm not sure we should? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I yanked it from 7.10 so it hasn't been released yet. This will be the first release in 7.11. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, I was going based on the PRs but didn't realize it had been pulled, LGTM then. |
||
"priority": 1000, | ||
"data_stream": { | ||
"hidden": true | ||
}, | ||
"composed_of": [ | ||
".deprecation-indexing-mappings", | ||
".deprecation-indexing-settings" | ||
], | ||
"allow_auto_create": true, | ||
"_meta": { | ||
"description": "default template for ES deprecation logs index template installed by x-pack", | ||
"managed": true | ||
}, | ||
"version": ${xpack.deprecation.indexing.template.version} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.deprecation.logging; | ||
|
||
import org.elasticsearch.client.Client; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.xpack.core.template.IndexTemplateConfig; | ||
import org.elasticsearch.xpack.core.template.IndexTemplateRegistry; | ||
import org.elasticsearch.xpack.core.template.LifecyclePolicyConfig; | ||
|
||
import java.util.List; | ||
|
||
import static org.elasticsearch.xpack.core.ClientHelper.DEPRECATION_ORIGIN; | ||
|
||
/** | ||
* Manages the index template and associated ILM policy for deprecation log indexing. | ||
*/ | ||
public class DeprecationIndexingTemplateRegistry extends IndexTemplateRegistry { | ||
// history (please add a comment why you increased the version here) | ||
// version 1: initial | ||
public static final int INDEX_TEMPLATE_VERSION = 1; | ||
|
||
public static final String DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE = "xpack.deprecation.indexing.template.version"; | ||
|
||
public static final String DEPRECATION_INDEXING_MAPPINGS_NAME = ".deprecation-indexing-mappings"; | ||
public static final String DEPRECATION_INDEXING_SETTINGS_NAME = ".deprecation-indexing-settings"; | ||
public static final String DEPRECATION_INDEXING_TEMPLATE_NAME = ".deprecation-indexing-template"; | ||
public static final String DEPRECATION_INDEXING_POLICY_NAME = ".deprecation-indexing-ilm-policy"; | ||
|
||
public static final IndexTemplateConfig DEPRECATION_INDEXING_MAPPINGS = new IndexTemplateConfig( | ||
DEPRECATION_INDEXING_MAPPINGS_NAME, | ||
"/org/elasticsearch/xpack/deprecation/deprecation-indexing-mappings.json", | ||
INDEX_TEMPLATE_VERSION, | ||
DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE | ||
); | ||
|
||
public static final IndexTemplateConfig DEPRECATION_INDEXING_SETTINGS = new IndexTemplateConfig( | ||
DEPRECATION_INDEXING_SETTINGS_NAME, | ||
"/org/elasticsearch/xpack/deprecation/deprecation-indexing-settings.json", | ||
INDEX_TEMPLATE_VERSION, | ||
DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE | ||
); | ||
|
||
public static final IndexTemplateConfig DEPRECATION_INDEXING_INDEX_TEMPLATE = new IndexTemplateConfig( | ||
DEPRECATION_INDEXING_TEMPLATE_NAME, | ||
"/org/elasticsearch/xpack/deprecation/deprecation-indexing-template.json", | ||
INDEX_TEMPLATE_VERSION, | ||
DEPRECATION_INDEXING_TEMPLATE_VERSION_VARIABLE | ||
); | ||
|
||
public static final LifecyclePolicyConfig DEPRECATION_INDEXING_HISTORY_POLICY = new LifecyclePolicyConfig( | ||
DEPRECATION_INDEXING_POLICY_NAME, | ||
"/org/elasticsearch/xpack/deprecation/deprecation-indexing-ilm-policy.json" | ||
); | ||
|
||
public DeprecationIndexingTemplateRegistry( | ||
Settings nodeSettings, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
Client client, | ||
NamedXContentRegistry xContentRegistry | ||
) { | ||
super(nodeSettings, clusterService, threadPool, client, xContentRegistry); | ||
} | ||
|
||
@Override | ||
protected List<IndexTemplateConfig> getComponentTemplateConfigs() { | ||
return List.of(DEPRECATION_INDEXING_MAPPINGS, DEPRECATION_INDEXING_SETTINGS); | ||
} | ||
|
||
@Override | ||
protected List<IndexTemplateConfig> getComposableTemplateConfigs() { | ||
return List.of(DEPRECATION_INDEXING_INDEX_TEMPLATE); | ||
} | ||
|
||
@Override | ||
protected List<LifecyclePolicyConfig> getPolicyConfigs() { | ||
return List.of(DEPRECATION_INDEXING_HISTORY_POLICY); | ||
} | ||
|
||
@Override | ||
protected String getOrigin() { | ||
return DEPRECATION_ORIGIN; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we create more fields from our logs. Do we have to define them in the mappings too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
dynamic_templates
part should take care of those.