forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[streams] wired stream lifecycle (elastic#207083)
Allows configuration of a wired stream's retention (root stream included) with dsl or ilm policy. The UI changes will be implemented separately, as well as the support for classic streams. A retention set on a stream is inherited to its eligible children when updated (ie not overriden). A lifecycle can be set with a `PUT kbn:/api/streams/:id` call: ``` // sets dlm policy with optional data_retention - no retention means data is kept indefinitely { "stream": { "ingest": { "lifecycle": { "dsl": { "data_retention": "7d" } }, ... } } } // sets ilm policy { "stream": { "ingest": { "lifecycle": { "ilm": { "policy": "my-policy" } }, ... } } } // removes any dlm/ilm set explicitly set on a stream and inherits the lifecycle of the closest parent // note that this cannot be applied to root stream { "stream": { "ingest": { "lifecycle": { "inherit": {} }, ... } } } // disables a lifecycle and stops inheriting parent's lifecycle and is also propagated to eligible children. this is effectively similar to dsl and ilm regarding the inheritance { "stream": { "ingest": { "lifecycle": { "disabled": {} }, ... } } } ``` When we set a retention, we update the targeted stream component template and data stream such as any new backing index created after the update will pick up for the new lifecycle, but we have to do extra work to apply the lifecycle to the existing backing indices. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
02455ff
commit 6370aa2
Showing
29 changed files
with
890 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
.../solutions/observability/packages/kbn-streams-schema/src/models/ingest/lifecycle/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import { z } from '@kbn/zod'; | ||
import { NonEmptyString } from '@kbn/zod-helpers'; | ||
import { createIsNarrowSchema } from '../../../helpers'; | ||
|
||
export interface IngestStreamLifecycleDSL { | ||
dsl: { | ||
data_retention?: string; | ||
}; | ||
} | ||
|
||
export interface IngestStreamLifecycleILM { | ||
ilm: { | ||
policy: string; | ||
}; | ||
} | ||
|
||
export interface IngestStreamLifecycleInherit { | ||
inherit: {}; | ||
} | ||
|
||
export interface IngestStreamLifecycleDisabled { | ||
disabled: {}; | ||
} | ||
|
||
export type IngestStreamLifecycle = | ||
| IngestStreamLifecycleDSL | ||
| IngestStreamLifecycleILM | ||
| IngestStreamLifecycleInherit | ||
| IngestStreamLifecycleDisabled; | ||
|
||
const dslLifecycleSchema = z.object({ | ||
dsl: z.object({ data_retention: z.optional(NonEmptyString) }), | ||
}); | ||
const ilmLifecycleSchema = z.object({ ilm: z.object({ policy: NonEmptyString }) }); | ||
const inheritLifecycleSchema = z.object({ inherit: z.strictObject({}) }); | ||
const disabledLifecycleSchema = z.object({ disabled: z.strictObject({}) }); | ||
|
||
export const ingestStreamLifecycleSchema: z.Schema<IngestStreamLifecycle> = z.union([ | ||
dslLifecycleSchema, | ||
ilmLifecycleSchema, | ||
inheritLifecycleSchema, | ||
disabledLifecycleSchema, | ||
]); | ||
|
||
export type InheritedIngestStreamLifecycle = IngestStreamLifecycle & { from: string }; | ||
|
||
export const inheritedIngestStreamLifecycleSchema: z.Schema<InheritedIngestStreamLifecycle> = | ||
ingestStreamLifecycleSchema.and(z.object({ from: NonEmptyString })); | ||
|
||
export const isDslLifecycle = createIsNarrowSchema(ingestStreamLifecycleSchema, dslLifecycleSchema); | ||
|
||
export const isIlmLifecycle = createIsNarrowSchema(ingestStreamLifecycleSchema, ilmLifecycleSchema); | ||
|
||
export const isInheritLifecycle = createIsNarrowSchema( | ||
ingestStreamLifecycleSchema, | ||
inheritLifecycleSchema | ||
); | ||
|
||
export const isDisabledLifecycle = createIsNarrowSchema( | ||
ingestStreamLifecycleSchema, | ||
disabledLifecycleSchema | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.