Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions x-pack/solutions/observability/plugins/slo/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,23 @@ export const SUPPRESSED_PRIORITY_ACTION = {
export const LOCK_ID_RESOURCE_INSTALLER = 'slo:resource_installer';

export const SLO_MODEL_VERSION = 2;
export const SLO_RESOURCES_VERSION = 3.5;
export const SLO_RESOURCES_VERSION = 3.6;
export const SLO_RESOURCES_VERSION_MAJOR = 3;

export const SLI_COMPONENT_TEMPLATE_MAPPINGS_NAME = '.slo-observability.sli-mappings';
export const SLI_COMPONENT_TEMPLATE_SETTINGS_NAME = '.slo-observability.sli-settings';
export const SLI_INDEX_TEMPLATE_NAME = '.slo-observability.sli';
export const SLI_INDEX_TEMPLATE_PATTERN = `.slo-observability.sli-*`;
export const SLI_COMPONENT_TEMPLATE_MAPPINGS_NAME = `.slo-observability.sli-mappings-v${SLO_RESOURCES_VERSION}`;
export const SLI_COMPONENT_TEMPLATE_SETTINGS_NAME = `.slo-observability.sli-settings-v${SLO_RESOURCES_VERSION}`;

export const SLI_INDEX_TEMPLATE_NAME = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}`;
export const SLI_INDEX_TEMPLATE_PATTERN = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}*`;
export const SLI_DESTINATION_INDEX_NAME = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}`;
export const SLI_DESTINATION_INDEX_PATTERN = `.slo-observability.sli-v${SLO_RESOURCES_VERSION_MAJOR}*`;

export const SLI_INGEST_PIPELINE_INDEX_NAME_PREFIX = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}.`;

export const SUMMARY_COMPONENT_TEMPLATE_MAPPINGS_NAME = '.slo-observability.summary-mappings';
export const SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME = '.slo-observability.summary-settings';
export const SUMMARY_INDEX_TEMPLATE_NAME = '.slo-observability.summary';
export const SUMMARY_INDEX_TEMPLATE_PATTERN = `.slo-observability.summary-*`;
export const SUMMARY_COMPONENT_TEMPLATE_MAPPINGS_NAME = `.slo-observability.summary-mappings-v${SLO_RESOURCES_VERSION}`;
export const SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME = `.slo-observability.summary-settings-v${SLO_RESOURCES_VERSION}`;
export const SUMMARY_INDEX_TEMPLATE_NAME = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}`;
export const SUMMARY_INDEX_TEMPLATE_PATTERN = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}*`;
export const SUMMARY_DESTINATION_INDEX_NAME = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}`; // store the summary document generated by transform
export const SUMMARY_TEMP_INDEX_NAME = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}.temp`; // store the temporary summary document
export const SUMMARY_DESTINATION_INDEX_PATTERN = `.slo-observability.summary-v${SLO_RESOURCES_VERSION_MAJOR}*`; // include temp and non-temp summary indices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
* 2.0.
*/

import type { ClusterPutComponentTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
import {
SLI_COMPONENT_TEMPLATE_SETTINGS_NAME,
SLO_RESOURCES_VERSION,
} from '../../../common/constants';

export const SLI_SETTINGS_TEMPLATE = {
export const SLI_SETTINGS_TEMPLATE: ClusterPutComponentTemplateRequest = {
name: SLI_COMPONENT_TEMPLATE_SETTINGS_NAME,
template: {
settings: {
'sort.field': ['slo.id', 'slo.revision', 'slo.instanceId'],
'sort.order': ['asc', 'asc', 'asc'],
auto_expand_replicas: '0-1',
hidden: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
* 2.0.
*/

import type { ClusterPutComponentTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
import {
SLO_RESOURCES_VERSION,
SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME,
} from '../../../common/constants';

export const SUMMARY_SETTINGS_TEMPLATE = {
export const SUMMARY_SETTINGS_TEMPLATE: ClusterPutComponentTemplateRequest = {
name: SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME,
template: {
settings: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import type { IndicesPutIndexTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
import {
SLI_COMPONENT_TEMPLATE_MAPPINGS_NAME,
SLI_COMPONENT_TEMPLATE_SETTINGS_NAME,
Expand All @@ -13,11 +14,11 @@ import {
SLO_RESOURCES_VERSION,
} from '../../../common/constants';

export const SLI_INDEX_TEMPLATE = {
export const SLI_INDEX_TEMPLATE: IndicesPutIndexTemplateRequest = {
name: SLI_INDEX_TEMPLATE_NAME,
index_patterns: [SLI_INDEX_TEMPLATE_PATTERN],
composed_of: [SLI_COMPONENT_TEMPLATE_MAPPINGS_NAME, SLI_COMPONENT_TEMPLATE_SETTINGS_NAME],
priority: 500,
priority: 600,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To override the previous index template matching on broader index pattern, e.g. .slo-observability.sli-* instead of .slo-observability.sli-v3.6* like now

_meta: {
description: 'Template for SLO rollup data',
version: SLO_RESOURCES_VERSION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import type { IndicesPutIndexTemplateRequest } from '@elastic/elasticsearch/lib/api/types';
import {
SLO_RESOURCES_VERSION,
SUMMARY_COMPONENT_TEMPLATE_MAPPINGS_NAME,
Expand All @@ -13,11 +14,11 @@ import {
SUMMARY_INDEX_TEMPLATE_PATTERN,
} from '../../../common/constants';

export const SUMMARY_INDEX_TEMPLATE = {
export const SUMMARY_INDEX_TEMPLATE: IndicesPutIndexTemplateRequest = {
name: SUMMARY_INDEX_TEMPLATE_NAME,
index_patterns: [SUMMARY_INDEX_TEMPLATE_PATTERN],
composed_of: [SUMMARY_COMPONENT_TEMPLATE_MAPPINGS_NAME, SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME],
priority: 500,
priority: 600,
_meta: {
description: 'SLO summary index template',
version: SLO_RESOURCES_VERSION,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const getSLIPipelineTemplate = (
date_index_name: {
field: '@timestamp',
index_name_prefix: SLI_INGEST_PIPELINE_INDEX_NAME_PREFIX,
date_rounding: 'M',
date_rounding: 'd',
date_formats: ['UNIX_MS', 'ISO8601', "yyyy-MM-dd'T'HH:mm:ss.SSSXX"],
},
},
Expand Down Expand Up @@ -100,6 +100,13 @@ export const getSLIPipelineTemplate = (
name: `slo-${slo.id}@custom`,
},
},
{
pipeline: {
ignore_missing_pipeline: true,
ignore_failure: true,
name: 'slo-rollup-global@custom',
},
},
],
_meta: {
description: 'Ingest pipeline for SLO rollup data',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,20 @@ export const getSummaryPipelineTemplate = (
ignore_failure: true,
},
},
{
pipeline: {
ignore_missing_pipeline: true,
ignore_failure: true,
name: `slo-${slo.id}@custom`,
},
},
{
pipeline: {
ignore_missing_pipeline: true,
ignore_failure: true,
name: 'slo-summary-global@custom',
},
},
],
_meta: {
description: `Ingest pipeline for SLO summary data [id: ${slo.id}, revision: ${slo.revision}]`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('slo transform template', () => {
},
defer_validation: true,
_meta: {
version: 3.5,
version: 3.6,
managed: true,
managed_by: 'observability',
},
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('slo transform template', () => {
},
defer_validation: true,
_meta: {
version: 3.5,
version: 3.6,
managed: true,
managed_by: 'observability',
},
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ export class DefaultResourceInstaller implements ResourceInstaller {
}

private async fetchComponentTemplateVersion(name: string) {
const getTemplateRes = await this.execute(() =>
const response = await this.execute(() =>
this.esClient.cluster.getComponentTemplate({ name }, { ignore: [404] })
);

return getTemplateRes?.component_templates?.[0]?.component_template?._meta?.version ?? null;
return response?.component_templates?.[0]?.component_template?._meta?.version ?? null;
}

private async fetchIndexTemplateVersion(name: string) {
const getTemplateRes = await this.execute(() =>
const response = await this.execute(() =>
this.esClient.indices.getIndexTemplate({ name }, { ignore: [404] })
);

return getTemplateRes?.index_templates?.[0]?.index_template?._meta?.version ?? null;
return response?.index_templates?.[0]?.index_template?._meta?.version ?? null;
}
}
Loading