-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rca): search and filter investigations (#192920)
- Loading branch information
Showing
24 changed files
with
568 additions
and
64 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
21 changes: 21 additions & 0 deletions
21
packages/kbn-investigation-shared/src/rest_specs/get_all_investigation_tags.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,21 @@ | ||
/* | ||
* 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", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { z } from '@kbn/zod'; | ||
|
||
const getAllInvestigationTagsParamsSchema = z.object({ | ||
query: z.object({}), | ||
}); | ||
|
||
const getAllInvestigationTagsResponseSchema = z.string().array(); | ||
|
||
type GetAllInvestigationTagsResponse = z.output<typeof getAllInvestigationTagsResponseSchema>; | ||
|
||
export { getAllInvestigationTagsParamsSchema, getAllInvestigationTagsResponseSchema }; | ||
export type { GetAllInvestigationTagsResponse }; |
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
59 changes: 59 additions & 0 deletions
59
...s/observability_solution/investigate_app/public/hooks/use_fetch_all_investigation_tags.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,59 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { investigationKeys } from './query_key_factory'; | ||
import { useKibana } from './use_kibana'; | ||
|
||
export interface Response { | ||
isInitialLoading: boolean; | ||
isLoading: boolean; | ||
isRefetching: boolean; | ||
isSuccess: boolean; | ||
isError: boolean; | ||
data: string[] | undefined; | ||
} | ||
|
||
export function useFetchAllInvestigationTags(): Response { | ||
const { | ||
core: { | ||
http, | ||
notifications: { toasts }, | ||
}, | ||
} = useKibana(); | ||
|
||
const { isInitialLoading, isLoading, isError, isSuccess, isRefetching, data } = useQuery({ | ||
queryKey: investigationKeys.tags(), | ||
queryFn: async ({ signal }) => { | ||
return await http.get<string[]>(`/api/observability/investigations/_tags`, { | ||
version: '2023-10-31', | ||
signal, | ||
}); | ||
}, | ||
cacheTime: 600 * 1000, // 10_minutes | ||
staleTime: 0, | ||
refetchOnWindowFocus: false, | ||
retry: false, | ||
onError: (error: Error) => { | ||
toasts.addError(error, { | ||
title: i18n.translate('xpack.investigateApp.useFetchAllInvestigationTags.errorTitle', { | ||
defaultMessage: 'Something went wrong while fetching the investigation tags', | ||
}), | ||
}); | ||
}, | ||
}); | ||
|
||
return { | ||
data, | ||
isInitialLoading, | ||
isLoading, | ||
isRefetching, | ||
isSuccess, | ||
isError, | ||
}; | ||
} |
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.