import { kqlQuery } from '../../../../observability/server' ; import { NodeType } from '../../../common/connections' ; import { environmentQuery } from '../../../common/utils/environment_query' ; import { getConnectionStats } from '../../lib/connections/get_connection_stats' ; import { getConnectionStatsItemsWithRelativeImpact } from '../../lib/connections/get_connection_stats/get_connection_stats_items_with_relative_impact' ; import { Setup } from '../../lib/helpers/setup_request' ; export async function getTopBackends ( { setup , start , end , numBuckets , environment , offset , kuery , } ) { const statsItems = await getConnectionStats ( { setup , start , end , numBuckets , filter : [ ... environmentQuery ( environment ) , ... kqlQuery ( kuery ) ] , offset , collapseBy : 'downstream' , } ) ; return getConnectionStatsItemsWithRelativeImpact ( statsItems . filter ( ( item ) => item . location . type !== NodeType . service ) ) ; }