-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Alert counts in Service groups (#144484)
Closes #143613 Closes #144420 ![Screen Shot 2022-11-03 at 7 32 39 PM](https://user-images.githubusercontent.com/1967266/199854883-9b4b5028-c2c6-46ca-93ce-cce37e31a213.png) ![apm-service-groups-alert-count](https://user-images.githubusercontent.com/1967266/199854840-70c17d59-5594-46c4-8fcb-d3e39e149d27.gif) ![Screen Shot 2022-11-03 at 7 34 41 PM](https://user-images.githubusercontent.com/1967266/199854863-149c638a-e978-41a7-bc3d-ccf1ccc7c53b.png) ![Screen Shot 2022-11-03 at 7 32 21 PM](https://user-images.githubusercontent.com/1967266/199854876-b49249b8-bfa7-4106-a9e8-632c794cffde.png) Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Miriam <[email protected]> Co-authored-by: miriam.aparicio <[email protected]>
- Loading branch information
1 parent
80a6e6c
commit 5ae469d
Showing
18 changed files
with
630 additions
and
132 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
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
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/apm/server/routes/service_groups/get_apm_alerts_client.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,42 @@ | ||
/* | ||
* 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 { isEmpty } from 'lodash'; | ||
import { APMRouteHandlerResources } from '../typings'; | ||
|
||
export type ApmAlertsClient = Awaited<ReturnType<typeof getApmAlertsClient>>; | ||
|
||
export async function getApmAlertsClient({ | ||
plugins, | ||
request, | ||
}: APMRouteHandlerResources) { | ||
const ruleRegistryPluginStart = await plugins.ruleRegistry.start(); | ||
const alertsClient = await ruleRegistryPluginStart.getRacClientWithRequest( | ||
request | ||
); | ||
const apmAlertsIndices = await alertsClient.getAuthorizedAlertsIndices([ | ||
'apm', | ||
]); | ||
|
||
if (!apmAlertsIndices || isEmpty(apmAlertsIndices)) { | ||
throw Error('No alert indices exist for "apm"'); | ||
} | ||
|
||
type ApmAlertsClientSearchParams = Omit< | ||
Parameters<typeof alertsClient.find>[0], | ||
'index' | ||
>; | ||
|
||
return { | ||
search(searchParams: ApmAlertsClientSearchParams) { | ||
return alertsClient.find({ | ||
...searchParams, | ||
index: apmAlertsIndices.join(','), | ||
}); | ||
}, | ||
}; | ||
} |
Oops, something went wrong.