Skip to content

Commit

Permalink
feat(slo): new slo architecture (#172224)
Browse files Browse the repository at this point in the history
(cherry picked from commit b51304f)
  • Loading branch information
kdelemme committed Dec 12, 2023
1 parent 2d81cce commit fd762cf
Show file tree
Hide file tree
Showing 104 changed files with 3,693 additions and 5,597 deletions.
3 changes: 2 additions & 1 deletion packages/kbn-check-mappings-update-cli/current_fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,8 @@
"indicator.params",
"indicator.type",
"name",
"tags"
"tags",
"version"
],
"threshold-explorer-view": [],
"observability-onboarding-state": [
Expand Down
3 changes: 3 additions & 0 deletions packages/kbn-check-mappings-update-cli/current_mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,9 @@
},
"tags": {
"type": "keyword"
},
"version": {
"type": "long"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('checking migration metadata changes on all registered SO types', () =>
"siem-ui-timeline": "d3de8ff3617be8f2a799d66b1471b9be6124bf40",
"siem-ui-timeline-note": "0a32fb776907f596bedca292b8c646496ae9c57b",
"siem-ui-timeline-pinned-event": "082daa3ce647b33873f6abccf340bdfa32057c8d",
"slo": "2048ab6791df2e1ae0936f29c20765cb8d2fcfaa",
"slo": "9a9995e4572de1839651c43b5fc4dc8276bb5815",
"space": "8de4ec513e9bbc6b2f1d635161d850be7747d38e",
"spaces-usage-stats": "3abca98713c52af8b30300e386c7779b3025a20e",
"synthetics-monitor": "33ddc4b8979f378edf58bcc7ba13c5c5b572f42d",
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/kbn-slo-schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
export * from './src/schema';
export * from './src/rest_specs';
export * from './src/models/duration';
export * from './src/models/pagination';
17 changes: 17 additions & 0 deletions x-pack/packages/kbn-slo-schema/src/models/pagination.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* 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.
*/
export interface Paginated<T> {
total: number;
page: number;
perPage: number;
results: T[];
}

export interface Pagination {
page: number;
perPage: number;
}
50 changes: 30 additions & 20 deletions x-pack/packages/kbn-slo-schema/src/rest_specs/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import * as t from 'io-ts';
import { toBooleanRt } from '@kbn/io-ts-utils';
import {
allOrAnyString,
apmTransactionDurationIndicatorSchema,
Expand Down Expand Up @@ -109,6 +110,7 @@ const sloResponseSchema = t.intersection([
groupBy: allOrAnyString,
createdAt: dateType,
updatedAt: dateType,
version: t.number,
}),
t.partial({
instanceId: allOrAnyString,
Expand Down Expand Up @@ -157,6 +159,12 @@ const manageSLOParamsSchema = t.type({
path: t.type({ id: sloIdSchema }),
});

const resetSLOParamsSchema = t.type({
path: t.type({ id: sloIdSchema }),
});

const resetSLOResponseSchema = sloResponseSchema;

const updateSLOResponseSchema = sloResponseSchema;

const findSLOResponseSchema = t.type({
Expand All @@ -182,23 +190,21 @@ const fetchHistoricalSummaryResponseSchema = t.array(
})
);

/**
* The query params schema for /internal/observability/slo/_definitions
*
* @private
*/
const findSloDefinitionsParamsSchema = t.type({
query: t.type({
const findSloDefinitionsParamsSchema = t.partial({
query: t.partial({
search: t.string,
includeOutdatedOnly: toBooleanRt,
page: t.string,
perPage: t.string,
}),
});

/**
* The response schema for /internal/observability/slo/_definitions
*
* @private
*/
const findSloDefinitionsResponseSchema = t.array(sloResponseSchema);
const findSloDefinitionsResponseSchema = t.type({
page: t.number,
perPage: t.number,
total: t.number,
results: t.array(sloResponseSchema),
});

const getSLOBurnRatesResponseSchema = t.type({
burnRates: t.array(
Expand Down Expand Up @@ -244,6 +250,9 @@ type GetSLOResponse = t.OutputOf<typeof getSLOResponseSchema>;

type ManageSLOParams = t.TypeOf<typeof manageSLOParamsSchema.props.path>;

type ResetSLOParams = t.TypeOf<typeof resetSLOParamsSchema.props.path>;
type ResetSLOResponse = t.OutputOf<typeof resetSLOResponseSchema>;

type UpdateSLOInput = t.OutputOf<typeof updateSLOParamsSchema.props.body>;
type UpdateSLOParams = t.TypeOf<typeof updateSLOParamsSchema.props.body>;
type UpdateSLOResponse = t.OutputOf<typeof updateSLOResponseSchema>;
Expand All @@ -258,12 +267,8 @@ type FetchHistoricalSummaryParams = t.TypeOf<typeof fetchHistoricalSummaryParams
type FetchHistoricalSummaryResponse = t.OutputOf<typeof fetchHistoricalSummaryResponseSchema>;
type HistoricalSummaryResponse = t.OutputOf<typeof historicalSummarySchema>;

/**
* The response type for /internal/observability/slo/_definitions
*
* @private
*/
type FindSloDefinitionsResponse = t.OutputOf<typeof findSloDefinitionsResponseSchema>;
type FindSLODefinitionsParams = t.TypeOf<typeof findSloDefinitionsParamsSchema.props.query>;
type FindSLODefinitionsResponse = t.OutputOf<typeof findSloDefinitionsResponseSchema>;

type GetPreviewDataParams = t.TypeOf<typeof getPreviewDataParamsSchema.props.body>;
type GetPreviewDataResponse = t.OutputOf<typeof getPreviewDataResponseSchema>;
Expand Down Expand Up @@ -300,6 +305,8 @@ export {
findSloDefinitionsParamsSchema,
findSloDefinitionsResponseSchema,
manageSLOParamsSchema,
resetSLOParamsSchema,
resetSLOResponseSchema,
sloResponseSchema,
sloWithSummaryResponseSchema,
updateSLOParamsSchema,
Expand All @@ -325,8 +332,11 @@ export type {
FetchHistoricalSummaryParams,
FetchHistoricalSummaryResponse,
HistoricalSummaryResponse,
FindSloDefinitionsResponse,
FindSLODefinitionsParams,
FindSLODefinitionsResponse,
ManageSLOParams,
ResetSLOParams,
ResetSLOResponse,
SLOResponse,
SLOWithSummaryResponse,
UpdateSLOInput,
Expand Down
1 change: 1 addition & 0 deletions x-pack/packages/kbn-slo-schema/src/schema/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const sloSchema = t.type({
createdAt: dateType,
updatedAt: dateType,
groupBy: allOrAnyString,
version: t.number,
});

const sloWithSummarySchema = t.intersection([sloSchema, t.type({ summary: summarySchema })]);
Expand Down
3 changes: 2 additions & 1 deletion x-pack/packages/kbn-slo-schema/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"**/*.ts"
],
"kbn_references": [
"@kbn/std"
"@kbn/std",
"@kbn/io-ts-utils"
],
"exclude": [
"target/**/*",
Expand Down
4 changes: 2 additions & 2 deletions x-pack/performance/journeys/many_fields_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const journey = new Journey({
.step('Go to Transforms', async ({ page, kbnUrl, kibanaPage }) => {
await page.goto(kbnUrl.get(`app/management/data/transform`));
await kibanaPage.waitForHeader();
await page.waitForSelector(subj('transformButtonCreate'));
await page.waitForSelector(subj('transformCreateFirstButton'));
await page.waitForSelector(subj('globalLoadingIndicator-hidden'));
})
.step('Go to data view selection', async ({ page }) => {
const createButtons = page.locator(subj('transformButtonCreate'));
const createButtons = page.locator(subj('transformCreateFirstButton'));
await createButtons.first().click();
await page.waitForSelector(subj('savedObjectsFinderTable'));
})
Expand Down
16 changes: 9 additions & 7 deletions x-pack/plugins/observability/common/slo/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

export const SLO_RESOURCES_VERSION = 2;
export const SLO_SUMMARY_TRANSFORMS_VERSION = 3;
export const SLO_MODEL_VERSION = 2;
export const SLO_RESOURCES_VERSION = 3;

export const SLO_COMPONENT_TEMPLATE_MAPPINGS_NAME = '.slo-observability.sli-mappings';
export const SLO_COMPONENT_TEMPLATE_SETTINGS_NAME = '.slo-observability.sli-settings';
Expand All @@ -17,21 +17,23 @@ export const SLO_INDEX_TEMPLATE_PATTERN = `.slo-observability.sli-*`;
export const SLO_DESTINATION_INDEX_NAME = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}`;
export const SLO_DESTINATION_INDEX_PATTERN = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}*`;

export const SLO_INGEST_PIPELINE_NAME = `.slo-observability.sli.pipeline`;
// slo-observability.sli-v<version>.(YYYY-MM-DD)
export const SLO_INGEST_PIPELINE_NAME = `.slo-observability.sli.pipeline-v${SLO_RESOURCES_VERSION}`;
export const SLO_INGEST_PIPELINE_INDEX_NAME_PREFIX = `.slo-observability.sli-v${SLO_RESOURCES_VERSION}.`;

export const SLO_SUMMARY_COMPONENT_TEMPLATE_MAPPINGS_NAME = '.slo-observability.summary-mappings';
export const SLO_SUMMARY_COMPONENT_TEMPLATE_SETTINGS_NAME = '.slo-observability.summary-settings';
export const SLO_SUMMARY_INDEX_TEMPLATE_NAME = '.slo-observability.summary';
export const SLO_SUMMARY_INDEX_TEMPLATE_PATTERN = `.slo-observability.summary-*`;

export const SLO_SUMMARY_TRANSFORM_NAME_PREFIX = 'slo-summary-';
export const SLO_SUMMARY_DESTINATION_INDEX_NAME = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}`; // store the temporary summary document generated by transform
export const SLO_SUMMARY_TEMP_INDEX_NAME = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}.temp`; // store the temporary summary document
export const SLO_SUMMARY_DESTINATION_INDEX_PATTERN = `.slo-observability.summary-v${SLO_RESOURCES_VERSION}*`; // include temp and non-temp summary indices

export const SLO_SUMMARY_INGEST_PIPELINE_NAME = `.slo-observability.summary.pipeline`;

export const getSLOTransformId = (sloId: string, sloRevision: number) =>
`slo-${sloId}-${sloRevision}`;

export const getSLOSummaryTransformId = (sloId: string, sloRevision: number) =>
`slo-summary-${sloId}-${sloRevision}`;

export const getSLOSummaryPipelineId = (sloId: string, sloRevision: number) =>
`.slo-observability.summary.pipeline-${sloId}-${sloRevision}`;
Loading

0 comments on commit fd762cf

Please sign in to comment.