diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.test.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.test.ts index d69fd167ee117..7ea61bde7a0e8 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.test.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.test.ts @@ -39,6 +39,14 @@ describe('Install pipeline tests', () => { await res.install(esClient, logger); expect(esClient.ingest.putPipeline).toBeCalled(); + + // It should add the @custom pipeline for the main pipeline + const pipelinesWithCustomProcessor = esClient.ingest.putPipeline.mock.calls.filter((call) => + // @ts-ignore-error + call[0]?.body.includes('@custom') + ); + + expect(pipelinesWithCustomProcessor).toHaveLength(1); }); it('should work with datastream with ingest pipelines define in the package', async () => { @@ -73,6 +81,14 @@ describe('Install pipeline tests', () => { await res.install(esClient, logger); expect(esClient.ingest.putPipeline).toBeCalledTimes(2); + + // It should add the @custom pipeline only for the main pipeline + const pipelinesWithCustomProcessor = esClient.ingest.putPipeline.mock.calls.filter((call) => + // @ts-ignore-error + call[0]?.body.includes('@custom') + ); + + expect(pipelinesWithCustomProcessor).toHaveLength(1); }); }); }); diff --git a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts index 2d9fdb31036e7..7ada81c26c926 100644 --- a/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts +++ b/x-pack/plugins/fleet/server/services/epm/elasticsearch/ingest_pipeline/install.ts @@ -157,7 +157,8 @@ export async function installAllPipelines({ let datastreamPipelineCreated = false; pipelinePaths.forEach((path) => { const { name, extension } = getNameAndExtension(path); - if (name === dataStream?.ingest_pipeline) { + const isMainPipeline = name === dataStream?.ingest_pipeline; + if (isMainPipeline) { datastreamPipelineCreated = true; } const nameForInstallation = getPipelineNameForInstallation({ @@ -168,9 +169,8 @@ export async function installAllPipelines({ const content = getAsset(path).toString('utf-8'); pipelinesInfos.push({ nameForInstallation, - customIngestPipelineNameForInstallation: dataStream - ? getCustomPipelineNameForDatastream(dataStream) - : undefined, + customIngestPipelineNameForInstallation: + dataStream && isMainPipeline ? getCustomPipelineNameForDatastream(dataStream) : undefined, content, extension, });