-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Add pipeline to clean docs during data stream reindex #121617
Changes from all commits
b3e2466
68d8e77
7916c28
aefea5b
369aec9
0d444d9
c8178ba
0b26eec
7fc1a0f
f2356b8
4d6cd6e
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,16 @@ | ||
{ | ||
"description": "This pipeline sanitizes documents that are being reindexed into a data stream using the reindex data stream API. It is an internal pipeline and should not be modified.", | ||
"processors": [ | ||
{ | ||
"set": { | ||
"field": "@timestamp", | ||
"value": 0, | ||
"override": false | ||
} | ||
} | ||
], | ||
"_meta": { | ||
"managed": true | ||
}, | ||
"version": ${xpack.migrate.reindex.pipeline.version} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.migrate; | ||
|
||
import org.elasticsearch.client.internal.Client; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.xcontent.NamedXContentRegistry; | ||
import org.elasticsearch.xpack.core.ClientHelper; | ||
import org.elasticsearch.xpack.core.template.IndexTemplateRegistry; | ||
import org.elasticsearch.xpack.core.template.IngestPipelineConfig; | ||
import org.elasticsearch.xpack.core.template.JsonIngestPipelineConfig; | ||
|
||
import java.util.List; | ||
|
||
public class MigrateTemplateRegistry extends IndexTemplateRegistry { | ||
|
||
// This number must be incremented when we make changes to built-in pipeline. | ||
// If a specific user pipeline is needed instead, its version should be set to a value higher than the REGISTRY_VERSION. | ||
static final int REGISTRY_VERSION = 1; | ||
public static final String REINDEX_DATA_STREAM_PIPELINE_NAME = "reindex-data-stream-pipeline"; | ||
private static final String TEMPLATE_VERSION_VARIABLE = "xpack.migrate.reindex.pipeline.version"; | ||
|
||
public MigrateTemplateRegistry( | ||
Settings nodeSettings, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
Client client, | ||
NamedXContentRegistry xContentRegistry | ||
) { | ||
super(nodeSettings, clusterService, threadPool, client, xContentRegistry); | ||
} | ||
|
||
@Override | ||
protected List<IngestPipelineConfig> getIngestPipelines() { | ||
return List.of( | ||
new JsonIngestPipelineConfig( | ||
REINDEX_DATA_STREAM_PIPELINE_NAME, | ||
"/" + REINDEX_DATA_STREAM_PIPELINE_NAME + ".json", | ||
REGISTRY_VERSION, | ||
TEMPLATE_VERSION_VARIABLE | ||
) | ||
); | ||
} | ||
|
||
@Override | ||
protected String getOrigin() { | ||
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. Since this no longer needs to be run with the user permissions, it seemed better to not require the user to have put-pipeline, and to make new user with system perms (or something like that) and only give it to this registry. 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 definitely agree. |
||
return ClientHelper.STACK_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.
Since version is now handled by the index template registry, the way to keep it from overwriting a custom template is to use a higher version number.