Skip to content

Commit a167c9e

Browse files
[8.x] Add SLO Definition Page (#215423) (#218120)
# Backport This will backport the following commits from `main` to `8.x`: - [Add SLO Definition Page (#215423)](#215423) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Bailey Cash","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-03-26T12:23:55Z","message":"Add SLO Definition Page (#215423)","sha":"8aa9b82079a3e38548ac5919c623591beb057ac0","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:skip","Team:obs-ux-management","v9.1.0"],"title":"Add SLO Definition Page","number":215423,"url":"https://github.com/elastic/kibana/pull/215423","mergeCommit":{"message":"Add SLO Definition Page (#215423)","sha":"8aa9b82079a3e38548ac5919c623591beb057ac0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/215423","number":215423,"mergeCommit":{"message":"Add SLO Definition Page (#215423)","sha":"8aa9b82079a3e38548ac5919c623591beb057ac0"}}]}] BACKPORT-->
1 parent 8e6ff32 commit a167c9e

File tree

17 files changed

+585
-13
lines changed

17 files changed

+585
-13
lines changed

src/platform/test/plugin_functional/test_suites/core_plugins/rendering.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
379379
'xpack.apm.featureFlags.ruleFormV2Enabled (boolean?)',
380380
'xpack.observability.unsafe.ruleFormV2.enabled (boolean?)',
381381
'xpack.slo.experimental.ruleFormV2.enabled (boolean?)',
382+
'xpack.slo.experimental.management.enabled (boolean?)',
382383
/**/
383384
];
384385
// We don't assert that actualExposedConfigKeys and expectedExposedConfigKeys are equal, because test failure messages with large

x-pack/solutions/observability/plugins/slo/common/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export const configSchema = schema.object({
1616
ruleFormV2: schema.object({
1717
enabled: schema.boolean({ defaultValue: false }),
1818
}),
19+
management: schema.object({
20+
enabled: schema.boolean({ defaultValue: false }),
21+
}),
1922
})
2023
),
2124
});

x-pack/solutions/observability/plugins/slo/common/locators/paths.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ export const SLO_CREATE_PATH = '/create' as const;
1515
export const SLO_EDIT_PATH = '/edit/:sloId' as const;
1616
export const SLOS_OUTDATED_DEFINITIONS_PATH = '/outdated-definitions' as const;
1717
export const SLO_SETTINGS_PATH = '/settings' as const;
18+
export const SLOS_MANAGEMENT_PATH = '/management' as const;
1819

1920
export const paths = {
2021
slos: `${SLOS_BASE_PATH}${SLOS_PATH}`,
2122
slosSettings: `${SLOS_BASE_PATH}${SLO_SETTINGS_PATH}`,
2223
slosWelcome: `${SLOS_BASE_PATH}${SLOS_WELCOME_PATH}`,
24+
slosManagement: `${SLOS_BASE_PATH}${SLOS_MANAGEMENT_PATH}`,
2325
slosOutdatedDefinitions: `${SLOS_BASE_PATH}${SLOS_OUTDATED_DEFINITIONS_PATH}`,
2426
sloCreate: `${SLOS_BASE_PATH}${SLO_CREATE_PATH}`,
2527
sloCreateWithEncodedForm: (encodedParams: string) =>

x-pack/solutions/observability/plugins/slo/public/application.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ export const renderApp = ({
140140
};
141141

142142
function App() {
143-
const { isServerless } = usePluginContext();
143+
const { isServerless, experimentalFeatures } = usePluginContext();
144144

145-
const routes = getRoutes(isServerless);
145+
const routes = getRoutes(isServerless, experimentalFeatures);
146146

147147
return (
148148
<Routes enableExecutionContextTracking={true}>

x-pack/solutions/observability/plugins/slo/public/hooks/query_key_factory.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ export const sloKeys = {
5151
historicalSummaries: () => [...sloKeys.all, 'historicalSummary'] as const,
5252
historicalSummary: (list: Array<{ sloId: string; instanceId: string }>) =>
5353
[...sloKeys.historicalSummaries(), list] as const,
54-
definitions: (search: string, page: number, perPage: number, includeOutdatedOnly: boolean) =>
55-
[...sloKeys.all, 'definitions', search, page, perPage, includeOutdatedOnly] as const,
54+
allDefinitions: () => [...sloKeys.all, 'definitions'],
55+
definitions: (params: {
56+
search: string;
57+
page: number;
58+
perPage: number;
59+
includeOutdatedOnly: boolean;
60+
}) => [...sloKeys.allDefinitions(), params],
5661
globalDiagnosis: () => [...sloKeys.all, 'globalDiagnosis'] as const,
5762
health: (list: Array<{ sloId: string; sloInstanceId: string }>) =>
5863
[...sloKeys.all, 'health', list] as const,

x-pack/solutions/observability/plugins/slo/public/hooks/use_clone_slo.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { encode } from '@kbn/rison';
9-
import { SLOWithSummaryResponse } from '@kbn/slo-schema';
9+
import { SLODefinitionResponse, SLOWithSummaryResponse } from '@kbn/slo-schema';
1010
import { useCallback } from 'react';
1111
import { paths } from '../../common/locators/paths';
1212
import { useKibana } from './use_kibana';
@@ -21,8 +21,8 @@ export function useCloneSlo() {
2121
const spaceId = useSpace();
2222

2323
return useCallback(
24-
(slo: SLOWithSummaryResponse) => {
25-
if (slo.remote) {
24+
(slo: SLOWithSummaryResponse | SLODefinitionResponse) => {
25+
if ('remote' in slo && slo.remote) {
2626
window.open(createRemoteSloCloneUrl(slo, spaceId), '_blank');
2727
} else {
2828
const clonePath = paths.sloCreateWithEncodedForm(

x-pack/solutions/observability/plugins/slo/public/hooks/use_delete_slo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export function useDeleteSlo() {
4343
},
4444
onSuccess: (_data, { name }) => {
4545
queryClient.invalidateQueries({ queryKey: sloKeys.lists(), exact: false });
46+
queryClient.invalidateQueries({ queryKey: sloKeys.allDefinitions(), exact: false });
4647

4748
toasts.addSuccess(
4849
i18n.translate('xpack.slo.slo.delete.successNotification', {

x-pack/solutions/observability/plugins/slo/public/hooks/use_disable_slo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export function useDisableSlo() {
4444
onSuccess: (_data, { name }) => {
4545
queryClient.invalidateQueries({ queryKey: sloKeys.lists(), exact: false });
4646
queryClient.invalidateQueries({ queryKey: sloKeys.details(), exact: false });
47+
queryClient.invalidateQueries({ queryKey: sloKeys.allDefinitions(), exact: false });
4748

4849
toasts.addSuccess(
4950
i18n.translate('xpack.slo.disable.successNotification', {

x-pack/solutions/observability/plugins/slo/public/hooks/use_enable_slo.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export function useEnableSlo() {
4444
onSuccess: (_data, { name }) => {
4545
queryClient.invalidateQueries({ queryKey: sloKeys.lists(), exact: false });
4646
queryClient.invalidateQueries({ queryKey: sloKeys.details(), exact: false });
47+
queryClient.invalidateQueries({
48+
queryKey: sloKeys.allDefinitions(),
49+
exact: false,
50+
});
4751

4852
toasts.addSuccess(
4953
i18n.translate('xpack.slo.enable.successNotification', {

x-pack/solutions/observability/plugins/slo/public/hooks/use_fetch_slo_definitions.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface UseFetchSloDefinitionsResponse {
1818
refetch: () => void;
1919
}
2020

21-
interface Params {
21+
interface SLODefinitionParams {
2222
name?: string;
2323
includeOutdatedOnly?: boolean;
2424
page?: number;
@@ -30,17 +30,22 @@ export function useFetchSloDefinitions({
3030
includeOutdatedOnly = false,
3131
page = 1,
3232
perPage = 100,
33-
}: Params): UseFetchSloDefinitionsResponse {
33+
}: SLODefinitionParams): UseFetchSloDefinitionsResponse {
3434
const { sloClient } = usePluginContext();
3535
const search = name.endsWith('*') ? name : `${name}*`;
3636

3737
const { isLoading, isError, isSuccess, data, refetch } = useQuery({
38-
queryKey: sloKeys.definitions(search, page, perPage, includeOutdatedOnly),
38+
queryKey: sloKeys.definitions({ search, page, perPage, includeOutdatedOnly }),
3939
queryFn: async ({ signal }) => {
4040
try {
4141
return await sloClient.fetch('GET /api/observability/slos/_definitions 2023-10-31', {
4242
params: {
43-
query: { search, includeOutdatedOnly, page: String(page), perPage: String(perPage) },
43+
query: {
44+
...(search !== undefined && { search }),
45+
...(includeOutdatedOnly !== undefined && { includeOutdatedOnly }),
46+
...(page !== undefined && { page: String(page) }),
47+
...(perPage !== undefined && { perPage: String(perPage) }),
48+
},
4449
},
4550
signal,
4651
});

0 commit comments

Comments
 (0)