-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Service groups - dynamic query refresh (#140406)
* Service groups - dynamic query refresh * fixes bug with group save API which omits the query params * don't render 0 services if no services count is given * adds support for dynamic refresh in getSortedAndFilteredServices * only include a whitelisted set of metric doc fields in kuery bar suggestions * clean up unused i18n translation * address PR feedback * fixes bug with a bad translation variable reference Co-authored-by: Oliver Gupte <oliver.gupte@elastic.co>
- Loading branch information
Showing
20 changed files
with
290 additions
and
73 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
55 changes: 55 additions & 0 deletions
55
x-pack/plugins/apm/server/routes/service_groups/get_services_counts.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,55 @@ | ||
/* | ||
* 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 { ProcessorEvent } from '@kbn/observability-plugin/common'; | ||
import { rangeQuery, kqlQuery } from '@kbn/observability-plugin/server'; | ||
import { Setup } from '../../lib/helpers/setup_request'; | ||
import { SERVICE_NAME } from '../../../common/elasticsearch_fieldnames'; | ||
|
||
export async function getServicesCounts({ | ||
setup, | ||
kuery, | ||
maxNumberOfServices, | ||
start, | ||
end, | ||
}: { | ||
setup: Setup; | ||
kuery: string; | ||
maxNumberOfServices: number; | ||
start: number; | ||
end: number; | ||
}) { | ||
const { apmEventClient } = setup; | ||
|
||
const response = await apmEventClient.search('get_services_count', { | ||
apm: { | ||
events: [ | ||
ProcessorEvent.metric, | ||
ProcessorEvent.transaction, | ||
ProcessorEvent.span, | ||
ProcessorEvent.error, | ||
], | ||
}, | ||
body: { | ||
size: 0, | ||
query: { | ||
bool: { | ||
filter: [...rangeQuery(start, end), ...kqlQuery(kuery)], | ||
}, | ||
}, | ||
aggs: { | ||
services_count: { | ||
cardinality: { | ||
field: SERVICE_NAME, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
return response?.aggregations?.services_count.value ?? 0; | ||
} |
Oops, something went wrong.