-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(slo): new slo architecture #172224
feat(slo): new slo architecture #172224
Changes from all commits
7af9763
a6c43d1
35a47ff
0054826
e501670
0f0ba55
36dd2c1
ddac8ac
978af77
c03fc00
518f332
59828f8
31aae41
0c1151b
bd1e9a2
301af21
0816470
1e8ff20
59c4616
1fccef9
9dcc83b
ab41c81
ff2ccd5
90f6862
07d01c9
4e9e79d
2d4fcd2
93dda8e
32ca0de
6da956a
674c9a3
a5a32af
552f2a5
3965b9d
0477c2b
2409786
19c42ab
f5b4d5b
58a55cc
872b2b4
7df1340
6d8b5f3
a131262
51cc327
8936128
a7951c3
cf89bca
12e9746
ce00951
6ccd372
5319c6a
193e0f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2379,6 +2379,9 @@ | |
}, | ||
"tags": { | ||
"type": "keyword" | ||
}, | ||
"version": { | ||
"type": "long" | ||
} | ||
} | ||
}, | ||
|
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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
*/ | ||
|
||
import * as t from 'io-ts'; | ||
import { toBooleanRt } from '@kbn/io-ts-utils'; | ||
import { | ||
allOrAnyString, | ||
apmTransactionDurationIndicatorSchema, | ||
|
@@ -109,6 +110,7 @@ const sloResponseSchema = t.intersection([ | |
groupBy: allOrAnyString, | ||
createdAt: dateType, | ||
updatedAt: dateType, | ||
version: t.number, | ||
}), | ||
t.partial({ | ||
instanceId: allOrAnyString, | ||
|
@@ -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({ | ||
|
@@ -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({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you reuse this schema to generate the Pagination type? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More generally, I want to go through all these files and refactor them. I think the project grew, and we lost control on the schema/rest_specs/models. I think it would be good to spend some time thinking how to structure all these types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
page: t.number, | ||
perPage: t.number, | ||
total: t.number, | ||
results: t.array(sloResponseSchema), | ||
}); | ||
|
||
const getSLOBurnRatesResponseSchema = t.type({ | ||
burnRates: t.array( | ||
|
@@ -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>; | ||
|
@@ -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>; | ||
|
@@ -300,6 +305,8 @@ export { | |
findSloDefinitionsParamsSchema, | ||
findSloDefinitionsResponseSchema, | ||
manageSLOParamsSchema, | ||
resetSLOParamsSchema, | ||
resetSLOResponseSchema, | ||
sloResponseSchema, | ||
sloWithSummaryResponseSchema, | ||
updateSLOParamsSchema, | ||
|
@@ -325,8 +332,11 @@ export type { | |
FetchHistoricalSummaryParams, | ||
FetchHistoricalSummaryResponse, | ||
HistoricalSummaryResponse, | ||
FindSloDefinitionsResponse, | ||
FindSLODefinitionsParams, | ||
FindSLODefinitionsResponse, | ||
ManageSLOParams, | ||
ResetSLOParams, | ||
ResetSLOResponse, | ||
SLOResponse, | ||
SLOWithSummaryResponse, | ||
UpdateSLOInput, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These values don't get bumped? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The SLO_MODEL_VERSION is bumped to 2 (set to 1 by the Saved Object migration, therefore existing SLO prior to the upgrade will have an internal version of 1). SLO_RESOURCES_VERSION is bumped to 3 |
||
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'; | ||
|
@@ -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}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could reuse this in
Paginated<T>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could tackle that in this #172617