Skip to content

Commit

Permalink
Add reference to ecs@mappings for each index template (elastic#174855)
Browse files Browse the repository at this point in the history
## Summary

I added a reference to the component template `ecs@mappings` when
building any index template for an integration.

The same behaviour is valid for both logs and metrics index templates.

Linked to elastic/integrations#8542

Close elastic#174905

### Checklist

Delete any items that are not applicable to this PR.

- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kyle Pollich <[email protected]>
Co-authored-by: Felix Barnsteiner <[email protected]>
  • Loading branch information
3 people authored and WafaaNasr committed Feb 6, 2024
1 parent 022b03b commit ab766a1
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/server/constants/fleet_es_assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getESAssetMetadata } from '../services/epm/elasticsearch/meta';

const meta = getESAssetMetadata();

export const FLEET_INSTALL_FORMAT_VERSION = '1.1.0';
export const FLEET_INSTALL_FORMAT_VERSION = '1.2.0';

export const FLEET_AGENT_POLICIES_SCHEMA_VERSION = '1.1.1';

Expand Down Expand Up @@ -84,11 +84,13 @@ export const FLEET_COMPONENT_TEMPLATES = [
export const STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS = `logs@settings`;
export const STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS = `metrics@settings`;
export const STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS = `metrics@tsdb-settings`;
export const STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS = 'ecs@mappings';

export const STACK_COMPONENT_TEMPLATES = [
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
STACK_COMPONENT_TEMPLATE_METRICS_SETTINGS,
STACK_COMPONENT_TEMPLATE_METRICS_TSDB_SETTINGS,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
];

export const FLEET_FINAL_PIPELINE_VERSION = 4;
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/server/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export {
} from '../../common/constants';

export {
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
FLEET_GLOBALS_COMPONENT_TEMPLATE_CONTENT,
FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { processFields } from '../../fields/field';
import type { Field } from '../../fields/field';
import {
FLEET_COMPONENT_TEMPLATES,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
} from '../../../../constants';

Expand Down Expand Up @@ -82,6 +83,7 @@ describe('EPM template', () => {
expect(template.composed_of).toStrictEqual([
'logs@settings',
...composedOfTemplates,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
...FLEET_COMPONENT_TEMPLATES_NAMES,
]);
});
Expand All @@ -101,6 +103,7 @@ describe('EPM template', () => {
expect(template.composed_of).toStrictEqual([
'metrics@tsdb-settings',
...composedOfTemplates,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
...FLEET_COMPONENT_TEMPLATES_NAMES,
]);
});
Expand All @@ -125,6 +128,7 @@ describe('EPM template', () => {
expect(template.composed_of).toStrictEqual([
'logs@settings',
...composedOfTemplates,
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
]);
});
Expand All @@ -143,6 +147,7 @@ describe('EPM template', () => {
});
expect(template.composed_of).toStrictEqual([
'logs@settings',
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
...FLEET_COMPONENT_TEMPLATES_NAMES,
]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import type {
import { appContextService } from '../../..';
import { getRegistryDataStreamAssetBaseName } from '../../../../../common/services';
import {
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME,
STACK_COMPONENT_TEMPLATE_LOGS_SETTINGS,
Expand Down Expand Up @@ -113,6 +114,7 @@ export function getTemplate({
template.composed_of = [
...esBaseComponents,
...(template.composed_of || []),
STACK_COMPONENT_TEMPLATE_ECS_MAPPINGS,
FLEET_GLOBALS_COMPONENT_TEMPLATE_NAME,
...(appContextService.getConfig()?.agentIdVerificationEnabled
? [FLEET_AGENT_ID_VERIFY_COMPONENT_TEMPLATE_NAME]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default function (providerContext: FtrProviderContext) {
expect(pipelineRes).to.have.property(FINAL_PIPELINE_ID);
const res = await es.indices.getIndexTemplate({ name: 'logs-log.log' });
expect(res.index_templates.length).to.be(FINAL_PIPELINE_VERSION);
expect(res.index_templates[0]?.index_template?.composed_of).to.contain('ecs@mappings');
expect(res.index_templates[0]?.index_template?.composed_of).to.contain('.fleet_globals-1');
expect(res.index_templates[0]?.index_template?.composed_of).to.contain(
'.fleet_agent_id_verification-1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function (providerContext: FtrProviderContext) {
`logs@settings`,
`${templateName}@package`,
`${templateName}@custom`,
`ecs@mappings`,
'.fleet_globals-1',
'.fleet_agent_id_verification-1',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ export default function (providerContext: FtrProviderContext) {
await es.indices.deleteIndexTemplate({ name: templateName });
};

describe('Package Policy - input package behavior', async function () {
// Tests are order-dependent and share state so can fail.
describe.skip('Package Policy - input package behavior', async function () {
skipIfNoDockerRegistry(providerContext);

let agentPolicyId: string;
Expand Down

0 comments on commit ab766a1

Please sign in to comment.