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
[SLO] Add support for group by to SLO burn rate rule #163434
Merged
simianhacker
merged 15 commits into
elastic:main
from
simianhacker:issue-163120-add-support-for-group-by-to-burn-rate-rule
Aug 10, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
3ec5316
[SLO] Add support for group by to SLO burn rate rule
simianhacker 7e083bc
removing unused code
simianhacker 897ceb2
Updating slo alert schema
simianhacker cd7e89b
Merge branch 'main' of github.com:elastic/kibana into issue-163120-ad…
simianhacker 28f58d5
Adding new hook for only fetching the SLO definitions directly from t…
simianhacker 8f048a8
Cleaning up PR
simianhacker b0e7029
Merge branch 'main' of github.com:elastic/kibana into issue-163120-ad…
simianhacker bca997d
Fixing tests
simianhacker 2440f08
Merge branch 'main' of github.com:elastic/kibana into issue-163120-ad…
simianhacker 384afa5
Fixing the alert labels to match reality
simianhacker ecb2b22
Refactoring active alerts interface; fixing type for badge story
simianhacker e34dd91
Merge branch 'main' of github.com:elastic/kibana into issue-163120-ad…
simianhacker ff8ad69
fixing type
simianhacker 217bc5c
Merge branch 'main' of github.com:elastic/kibana into issue-163120-ad…
simianhacker a80174a
Merge branch 'main' of github.com:elastic/kibana into issue-163120-ad…
simianhacker File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
57 changes: 57 additions & 0 deletions
57
x-pack/plugins/observability/public/hooks/slo/use_fetch_slo_definitions.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,57 @@ | ||
/* | ||
* 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 { | ||
QueryObserverResult, | ||
RefetchOptions, | ||
RefetchQueryFilters, | ||
useQuery, | ||
} from '@tanstack/react-query'; | ||
import { SLOResponse } from '@kbn/slo-schema'; | ||
import { useKibana } from '../../utils/kibana_react'; | ||
|
||
export interface UseFetchSloDefinitionsResponse { | ||
isLoading: boolean; | ||
isSuccess: boolean; | ||
isError: boolean; | ||
data: SLOResponse[] | undefined; | ||
refetch: <TPageData>( | ||
options?: (RefetchOptions & RefetchQueryFilters<TPageData>) | undefined | ||
) => Promise<QueryObserverResult<SLOResponse[], unknown>>; | ||
} | ||
|
||
interface Params { | ||
name?: string; | ||
size?: number; | ||
} | ||
|
||
export function useFetchSloDefinitions({ | ||
name = '', | ||
size = 10, | ||
}: Params): UseFetchSloDefinitionsResponse { | ||
const { savedObjects } = useKibana().services; | ||
const search = name.endsWith('*') ? name : `${name}*`; | ||
|
||
const { isLoading, isError, isSuccess, data, refetch } = useQuery({ | ||
queryKey: ['fetchSloDefinitions', search], | ||
queryFn: async () => { | ||
try { | ||
const response = await savedObjects.client.find<SLOResponse>({ | ||
simianhacker marked this conversation as resolved.
Show resolved
Hide resolved
|
||
type: 'slo', | ||
search, | ||
searchFields: ['name'], | ||
perPage: size, | ||
}); | ||
return response.savedObjects.map((so) => so.attributes); | ||
} catch (error) { | ||
throw new Error(`Something went wrong. Error: ${error}`); | ||
} | ||
}, | ||
}); | ||
|
||
return { isLoading, isError, isSuccess, data, refetch }; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍🏻 Nice abstraction