Skip to content

Commit

Permalink
[8.x] feat(slo): allow configuration of advanced settings from UI (el…
Browse files Browse the repository at this point in the history
…astic#200822) (elastic#203575)

# Backport

This will backport the following commits from `main` to `8.x`:
- [feat(slo): allow configuration of advanced settings from UI
(elastic#200822)](elastic#200822)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"kevin.delemme@elastic.co"},"sourceCommit":{"committedDate":"2024-12-02T21:19:17Z","message":"feat(slo):
allow configuration of advanced settings from UI
(elastic#200822)","sha":"8fe4c4419222f346bb6c953ca97422bd977e12f7","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport
missing","v9.0.0","release_note:feature","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.18.0"],"number":200822,"url":"https://github.com/elastic/kibana/pull/200822","mergeCommit":{"message":"feat(slo):
allow configuration of advanced settings from UI
(elastic#200822)","sha":"8fe4c4419222f346bb6c953ca97422bd977e12f7"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200822","number":200822,"mergeCommit":{"message":"feat(slo):
allow configuration of advanced settings from UI
(elastic#200822)","sha":"8fe4c4419222f346bb6c953ca97422bd977e12f7"}},{"branch":"8.x","label":"v8.18.0","labelRegex":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
  • Loading branch information
kdelemme authored Dec 13, 2024
1 parent 84267a2 commit 513a9c6
Show file tree
Hide file tree
Showing 65 changed files with 53,188 additions and 843 deletions.
51,869 changes: 51,869 additions & 0 deletions oas_docs/output/kibana.serverless.yaml

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43884,19 +43884,23 @@ components:
properties:
frequency:
default: 1m
description: Configure how often the transform runs, default 1m
description: The interval between checks for changes in the source data. The minimum value is 1m and the maximum is 59m. The default value is 1 minute.
example: 5m
type: string
preventInitialBackfill:
default: false
description: Prevents the transform from backfilling data when it starts.
description: Start aggregating data from the time the SLO is created, instead of backfilling data from the beginning of the time window.
example: true
type: boolean
syncDelay:
default: 1m
description: The synch delay to apply to the transform. Default 1m
description: The time delay in minutes between the current time and the latest source data time. Increasing the value will delay any alerting. The default value is 1 minute. The minimum value is 1m and the maximum is 359m. It should always be greater then source index refresh interval.
example: 5m
type: string
syncField:
description: The date field that is used to identify new documents in the source. It is strongly recommended to use a field that contains the ingest timestamp. If you use a different field, you might need to set the delay such that it accounts for data transmission delays. When unspecified, we use the indicator timestamp field.
example: event.ingested
type: string
title: Settings
type: object
SLOs_slo_definition_response:
Expand Down
18 changes: 14 additions & 4 deletions x-pack/packages/kbn-slo-schema/src/schema/slo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,26 @@ const objectiveSchema = t.intersection([
t.partial({ timesliceTarget: t.number, timesliceWindow: durationType }),
]);

const settingsSchema = t.type({
const settingsSchema = t.intersection([
t.type({
syncDelay: durationType,
frequency: durationType,
preventInitialBackfill: t.boolean,
}),
t.partial({ syncField: t.union([t.string, t.null]) }),
]);

const groupBySchema = allOrAnyStringOrArray;

const optionalSettingsSchema = t.partial({
syncDelay: durationType,
frequency: durationType,
preventInitialBackfill: t.boolean,
syncField: t.union([t.string, t.null]),
});

const groupBySchema = allOrAnyStringOrArray;

const optionalSettingsSchema = t.partial({ ...settingsSchema.props });
const tagsSchema = t.array(t.string);

// id cannot contain special characters and spaces
const sloIdSchema = new t.Type<string, string, unknown>(
'sloIdSchema',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1647,20 +1647,25 @@
"description": "Defines properties for SLO settings.",
"type": "object",
"properties": {
"syncField": {
"description": "The date field that is used to identify new documents in the source. It is strongly recommended to use a field that contains the ingest timestamp. If you use a different field, you might need to set the delay such that it accounts for data transmission delays. When unspecified, we use the indicator timestamp field.",
"type": "string",
"example": "event.ingested"
},
"syncDelay": {
"description": "The synch delay to apply to the transform. Default 1m",
"description": "The time delay in minutes between the current time and the latest source data time. Increasing the value will delay any alerting. The default value is 1 minute. The minimum value is 1m and the maximum is 359m. It should always be greater then source index refresh interval.",
"type": "string",
"default": "1m",
"example": "5m"
},
"frequency": {
"description": "Configure how often the transform runs, default 1m",
"description": "The interval between checks for changes in the source data. The minimum value is 1m and the maximum is 59m. The default value is 1 minute.",
"type": "string",
"default": "1m",
"example": "5m"
},
"preventInitialBackfill": {
"description": "Prevents the transform from backfilling data when it starts.",
"description": "Start aggregating data from the time the SLO is created, instead of backfilling data from the beginning of the time window.",
"type": "boolean",
"default": false,
"example": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1137,18 +1137,22 @@ components:
description: Defines properties for SLO settings.
type: object
properties:
syncField:
description: The date field that is used to identify new documents in the source. It is strongly recommended to use a field that contains the ingest timestamp. If you use a different field, you might need to set the delay such that it accounts for data transmission delays. When unspecified, we use the indicator timestamp field.
type: string
example: event.ingested
syncDelay:
description: The synch delay to apply to the transform. Default 1m
description: The time delay in minutes between the current time and the latest source data time. Increasing the value will delay any alerting. The default value is 1 minute. The minimum value is 1m and the maximum is 359m. It should always be greater then source index refresh interval.
type: string
default: 1m
example: 5m
frequency:
description: Configure how often the transform runs, default 1m
description: The interval between checks for changes in the source data. The minimum value is 1m and the maximum is 59m. The default value is 1 minute.
type: string
default: 1m
example: 5m
preventInitialBackfill:
description: Prevents the transform from backfilling data when it starts.
description: Start aggregating data from the time the SLO is created, instead of backfilling data from the beginning of the time window.
type: boolean
default: false
example: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ title: Settings
description: Defines properties for SLO settings.
type: object
properties:
syncField:
description: The date field that is used to identify new documents in the source. It is strongly recommended to use a field that contains the ingest timestamp. If you use a different field, you might need to set the delay such that it accounts for data transmission delays. When unspecified, we use the indicator timestamp field.
type: string
example: 'event.ingested'
syncDelay:
description: The synch delay to apply to the transform. Default 1m
description: The time delay in minutes between the current time and the latest source data time. Increasing the value will delay any alerting. The default value is 1 minute. The minimum value is 1m and the maximum is 359m. It should always be greater then source index refresh interval.
type: string
default: 1m
example: 5m
frequency:
description: Configure how often the transform runs, default 1m
description: The interval between checks for changes in the source data. The minimum value is 1m and the maximum is 59m. The default value is 1 minute.
type: string
default: 1m
example: 5m
preventInitialBackfill:
description: Prevents the transform from backfilling data when it starts.
description: Start aggregating data from the time the SLO is created, instead of backfilling data from the beginning of the time window.
type: boolean
default: false
example: true
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,3 @@ paths:
# $ref: "paths/s@{spaceid}@api@slos@_definitions.yaml"
"/s/{spaceId}/api/observability/slos/_delete_instances":
$ref: "paths/s@{spaceid}@api@slos@_delete_instances.yaml"
# Security is defined when files are joined in oas_docs
# components:
# securitySchemes:
# basicAuth:
# type: http
# scheme: basic
# apiKeyAuth:
# type: apiKey
# in: header
# name: Authorization
# description: 'e.g. Authorization: ApiKey base64AccessApiKey'
# security:
# - basicAuth: []
# - apiKeyAuth: []
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const baseSlo: Omit<SLOWithSummaryResponse, 'id'> = {
good: 'http_status: 2xx',
total: 'a query',
timestampField: 'custom_timestamp',
dataViewId: 'some-data-view-id',
},
},
timeWindow: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,21 @@ import { SloEditLocatorDefinition } from './slo_edit';
describe('SloEditLocator', () => {
const locator = new SloEditLocatorDefinition();

it('should return correct url when empty params are provided', async () => {
it('returns the correct url when empty params are provided', async () => {
const location = await locator.getLocation({});
expect(location.app).toEqual('slo');
expect(location.path).toEqual('/create?_a=()');
});

it('should return correct url when slo is provided', async () => {
const location = await locator.getLocation(buildSlo({ id: 'foo' }));
it('returns the correct url when slo id is provided', async () => {
const location = await locator.getLocation({ id: 'existing-slo-id' });
expect(location.path).toEqual('/edit/existing-slo-id');
});

it('returns the correct url when partial slo input is provided', async () => {
const location = await locator.getLocation(buildSlo({ id: undefined }));
expect(location.path).toEqual(
"/edit/foo?_a=(budgetingMethod:occurrences,createdAt:'2022-12-29T10:11:12.000Z',description:'some%20description%20useful',enabled:!t,groupBy:'*',groupings:(),id:foo,indicator:(params:(filter:'baz:%20foo%20and%20bar%20%3E%202',good:'http_status:%202xx',index:some-index,timestampField:custom_timestamp,total:'a%20query'),type:sli.kql.custom),instanceId:'*',meta:(),name:'super%20important%20level%20service',objective:(target:0.98),revision:1,settings:(frequency:'1m',preventInitialBackfill:!f,syncDelay:'1m'),summary:(errorBudget:(consumed:0.064,initial:0.02,isEstimated:!f,remaining:0.936),fiveMinuteBurnRate:0,oneDayBurnRate:0,oneHourBurnRate:0,sliValue:0.99872,status:HEALTHY),tags:!(k8s,production,critical),timeWindow:(duration:'30d',type:rolling),updatedAt:'2022-12-29T10:11:12.000Z',version:2)"
"/create?_a=(budgetingMethod:occurrences,createdAt:'2022-12-29T10:11:12.000Z',description:'some%20description%20useful',enabled:!t,groupBy:'*',groupings:(),indicator:(params:(dataViewId:some-data-view-id,filter:'baz:%20foo%20and%20bar%20%3E%202',good:'http_status:%202xx',index:some-index,timestampField:custom_timestamp,total:'a%20query'),type:sli.kql.custom),instanceId:'*',meta:(),name:'super%20important%20level%20service',objective:(target:0.98),revision:1,settings:(frequency:'1m',preventInitialBackfill:!f,syncDelay:'1m'),summary:(errorBudget:(consumed:0.064,initial:0.02,isEstimated:!f,remaining:0.936),fiveMinuteBurnRate:0,oneDayBurnRate:0,oneHourBurnRate:0,sliValue:0.99872,status:HEALTHY),tags:!(k8s,production,critical),timeWindow:(duration:'30d',type:rolling),updatedAt:'2022-12-29T10:11:12.000Z',version:2)"
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,34 @@
* 2.0.
*/

import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public';
import type { RecursivePartial } from '@elastic/charts';
import type { SerializableRecord } from '@kbn/utility-types';
import type { LocatorDefinition } from '@kbn/share-plugin/public';
import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/public';
import { sloEditLocatorID } from '@kbn/observability-plugin/common';
import type { CreateSLOForm } from '../pages/slo_edit/types';
import type { LocatorDefinition } from '@kbn/share-plugin/public';
import { CreateSLOInput } from '@kbn/slo-schema';
import { SLO_CREATE_PATH } from '../../common/locators/paths';

export type SloEditParams = RecursivePartial<CreateSLOForm>;

export interface SloEditLocatorParams extends SloEditParams, SerializableRecord {}
export type SloEditLocatorParams = RecursivePartial<CreateSLOInput>;

export class SloEditLocatorDefinition implements LocatorDefinition<SloEditLocatorParams> {
public readonly id = sloEditLocatorID;

public readonly getLocation = async (slo: SloEditLocatorParams) => {
if (!!slo.id) {
return {
app: 'slo',
path: `/edit/${encodeURIComponent(slo.id)}`,
state: {},
};
}

return {
app: 'slo',
path: setStateToKbnUrl<SloEditParams>(
path: setStateToKbnUrl<RecursivePartial<CreateSLOInput>>(
'_a',
{
...slo,
},
slo,
{ useHash: false, storeInHashQuery: false },
slo.id ? `/edit/${encodeURIComponent(String(slo.id))}` : `${SLO_CREATE_PATH}`
SLO_CREATE_PATH
),
state: {},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import { EuiFlexGrid, EuiPanel, EuiText, useIsWithinBreakpoints } from '@elastic/eui';
import numeral from '@elastic/numeral';
import { i18n } from '@kbn/i18n';
import { TagsList } from '@kbn/observability-shared-plugin/public';
import {
SLOWithSummaryResponse,
occurrencesBudgetingMethodSchema,
querySchema,
rollingTimeWindowTypeSchema,
SLOWithSummaryResponse,
} from '@kbn/slo-schema';
import React from 'react';
import { TagsList } from '@kbn/observability-shared-plugin/public';
import { DisplayQuery } from './display_query';
import { useKibana } from '../../../../hooks/use_kibana';
import {
BUDGETING_METHOD_OCCURRENCES,
Expand All @@ -26,9 +25,9 @@ import {
toIndicatorTypeLabel,
} from '../../../../utils/slo/labels';
import { ApmIndicatorOverview } from './apm_indicator_overview';
import { SyntheticsIndicatorOverview } from './synthetics_indicator_overview';

import { DisplayQuery } from './display_query';
import { OverviewItem } from './overview_item';
import { SyntheticsIndicatorOverview } from './synthetics_indicator_overview';

export interface Props {
slo: SLOWithSummaryResponse;
Expand Down Expand Up @@ -170,6 +169,19 @@ export function Overview({ slo }: Props) {
}
/>
)}

<OverviewItem
title={i18n.translate('xpack.slo.sloDetails.overview.settings.syncDelay', {
defaultMessage: 'Sync delay',
})}
subtitle={slo.settings.syncDelay}
/>
<OverviewItem
title={i18n.translate('xpack.slo.sloDetails.overview.settings.frequency', {
defaultMessage: 'Frequency',
})}
subtitle={slo.settings.frequency}
/>
</EuiFlexGrid>
</EuiPanel>
);
Expand Down
Loading

0 comments on commit 513a9c6

Please sign in to comment.