Skip to content

Commit 2a79659

Browse files
authored
[Fleet] Install only OTel component template mappings for otelcol inputs (#237165)
Use OTel mappings more strictly in OTel integrations. Main index template is still managed by Fleet, but only OTel component templates are used for mappings. Other templates are still used for Fleet-managed settings. Packages are not expected to define fields with this approach, but they still can. Fields, and `subobjects: false` are removed from test package. This needs to be adjusted in a follow up in package spec as packages are required to contain fields now.
1 parent bacb5d8 commit 2a79659

File tree

7 files changed

+12
-35
lines changed

7 files changed

+12
-35
lines changed

x-pack/platform/plugins/shared/fleet/cypress/e2e/input_packages_real.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('OTel input package with custom data stream type', () => {
131131
const agentPolicyId = 'test-otel-input-package-policy';
132132
const agentPolicyName = 'Test input package policy';
133133
const packagePolicyName = 'input-package-policy';
134-
const datasetName = 'check'; // Default from the package.
134+
const datasetName = 'httpcheckreceiver'; // Default from the package.
135135
const dataStreamType = 'logs';
136136

137137
before(() => {
Binary file not shown.

x-pack/platform/plugins/shared/fleet/server/constants/fleet_es_assets.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ export const OTEL_LOGS_COMPONENT_TEMPLATES = [
153153
OTEL_COMPONENT_SEMCONV_RESOURCE_TO_ECS_MAPPINGS,
154154
];
155155
export const OTEL_TRACES_COMPONENT_TEMPLATES = [
156-
STACK_COMPONENT_TEMPLATE_TRACES_MAPPINGS,
157-
STACK_COMPONENT_TEMPLATE_TRACES_SETTINGS,
158156
OTEL_COMPONENT_TEMPLATE_MAPPINGS,
159157
OTEL_COMPONENT_TEMPLATE_SETTINGS,
160158
OTEL_COMPONENT_SEMCONV_RESOURCE_TO_ECS_MAPPINGS,

x-pack/platform/plugins/shared/fleet/server/services/epm/elasticsearch/template/install.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ describe('EPM index template install', () => {
647647
},
648648
template: {
649649
mappings: {
650-
dynamic: true,
651650
dynamic_templates: undefined,
652651
properties: {
653652
test_dimension: {
@@ -798,7 +797,6 @@ describe('EPM index template install', () => {
798797
},
799798
template: {
800799
mappings: {
801-
dynamic: true,
802800
dynamic_templates: undefined,
803801
properties: {
804802
test_dimension: {

x-pack/platform/plugins/shared/fleet/server/services/epm/elasticsearch/template/install.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -428,17 +428,6 @@ export function buildComponentTemplates(params: {
428428
isSyntheticSourceEnabledByDefault ||
429429
isTimeSeriesEnabledByDefault);
430430

431-
const isPkgConfiguringDynamicSettings =
432-
Object.keys(mappingsRuntimeFields).length > 0 || indexTemplateMappings?.dynamic !== undefined;
433-
434-
// Setting overrides for otel input packages, but only if the packages don't explicitly disable dynamic mappings or use `dynamic: runtime`
435-
// Override the `dynamic: false` set in otel@mappings to avoid conflicts in case
436-
const shouldOverrideSettingsForOtelInputs = isOtelInputType && !isPkgConfiguringDynamicSettings;
437-
438-
// Override `subobjects: false` to avoid conflicts with traces-otel@mappings
439-
const shouldOverrideSettingsForOtelInputsTraces =
440-
shouldOverrideSettingsForOtelInputs && type === 'traces' && !indexTemplateMappings.runtime;
441-
442431
templatesMap[packageTemplateName] = {
443432
template: {
444433
settings: {
@@ -472,8 +461,6 @@ export function buildComponentTemplates(params: {
472461
: {}),
473462
dynamic_templates: mappingsDynamicTemplates.length ? mappingsDynamicTemplates : undefined,
474463
...omit(indexTemplateMappings, 'properties', 'dynamic_templates', 'runtime'),
475-
...(shouldOverrideSettingsForOtelInputs ? { dynamic: true } : {}),
476-
...(shouldOverrideSettingsForOtelInputsTraces ? { subobjects: undefined } : {}),
477464
},
478465
...(lifecycle ? { lifecycle } : {}),
479466
},

x-pack/platform/plugins/shared/fleet/server/services/epm/elasticsearch/template/template.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ import {
2727
OTEL_COMPONENT_TEMPLATE_TRACES_CUSTOM_MAPPINGS,
2828
OTEL_COMPONENT_TEMPLATE_TRACES_MAPPINGS,
2929
STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
30-
STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS,
31-
STACK_COMPONENT_TEMPLATE_TRACES_MAPPINGS,
32-
STACK_COMPONENT_TEMPLATE_TRACES_SETTINGS,
3330
} from '../../../../constants/fleet_es_assets';
3431

3532
import { createAppContextStartContractMock } from '../../../../mocks';
@@ -342,14 +339,11 @@ describe('EPM template', () => {
342339
});
343340

344341
expect(template.composed_of).toStrictEqual([
345-
STACK_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
346-
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
347342
OTEL_COMPONENT_TEMPLATE_MAPPINGS,
348343
OTEL_COMPONENT_TEMPLATE_SETTINGS,
349344
OTEL_COMPONENT_TEMPLATE_LOGS_MAPPINGS,
350345
OTEL_COMPONENT_SEMCONV_RESOURCE_TO_ECS_MAPPINGS,
351346
...composedOfTemplates,
352-
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
353347
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
354348
FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME,
355349
]);
@@ -373,14 +367,11 @@ describe('EPM template', () => {
373367
isOtelInputType: true,
374368
});
375369
expect(template.composed_of).toStrictEqual([
376-
STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS,
377370
OTEL_COMPONENT_TEMPLATE_MAPPINGS,
378371
OTEL_COMPONENT_TEMPLATE_SETTINGS,
379372
OTEL_COMPONENT_TEMPLATE_METRICS_MAPPINGS,
380373
OTEL_COMPONENT_SEMCONV_RESOURCE_TO_ECS_MAPPINGS,
381374
...composedOfTemplates,
382-
383-
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
384375
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
385376
FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME,
386377
]);
@@ -404,15 +395,11 @@ describe('EPM template', () => {
404395
isOtelInputType: true,
405396
});
406397
expect(template.composed_of).toStrictEqual([
407-
STACK_COMPONENT_TEMPLATE_TRACES_MAPPINGS,
408-
STACK_COMPONENT_TEMPLATE_TRACES_SETTINGS,
409398
OTEL_COMPONENT_TEMPLATE_MAPPINGS,
410399
OTEL_COMPONENT_TEMPLATE_SETTINGS,
411400
OTEL_COMPONENT_SEMCONV_RESOURCE_TO_ECS_MAPPINGS,
412401
OTEL_COMPONENT_TEMPLATE_TRACES_MAPPINGS,
413402
...composedOfTemplates,
414-
415-
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
416403
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
417404
FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME,
418405
]);

x-pack/platform/plugins/shared/fleet/server/services/epm/elasticsearch/template/template.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,15 @@ export function getTemplate({
121121
);
122122
}
123123

124-
const esBaseComponents = getBaseEsComponents(type, !!isIndexModeTimeSeries);
124+
const esBaseComponents = getBaseEsComponents(type, !!isIndexModeTimeSeries, isOtelInputType);
125125

126126
const isEventIngestedEnabled = (config?: FleetConfigType): boolean =>
127127
Boolean(!config?.agentIdVerificationEnabled && config?.eventIngestedEnabled);
128128

129129
template.composed_of = [
130130
...esBaseComponents,
131-
...(isOtelInputType ? getOtelBaseComponents(type) : []),
132131
...(template.composed_of || []),
133-
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
132+
...(isOtelInputType ? [] : [STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS]),
134133
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
135134
...(appContextService.getConfig()?.agentIdVerificationEnabled
136135
? [FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME]
@@ -144,7 +143,15 @@ export function getTemplate({
144143
return template;
145144
}
146145

147-
const getBaseEsComponents = (type: string, isIndexModeTimeSeries: boolean): string[] => {
146+
const getBaseEsComponents = (
147+
type: string,
148+
isIndexModeTimeSeries: boolean,
149+
isOTelInputType?: boolean
150+
): string[] => {
151+
if (isOTelInputType) {
152+
return getOtelBaseComponents(type);
153+
}
154+
148155
if (type === 'metrics') {
149156
if (isIndexModeTimeSeries) {
150157
return [STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS];

0 commit comments

Comments
 (0)