Skip to content

Commit

Permalink
[Fleet] Fix agent metrics aggregation for > 10 agents
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Nov 27, 2023
1 parent 0124a50 commit 1499155
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x-pack/plugins/fleet/server/services/agents/agent_metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import type { Agent } from '../../types';
import { appContextService } from '../app_context';
import { DATA_TIERS } from '../../../common/constants';

const AGGREGATION_MAX_SIZE = 1000;

export async function fetchAndAssignAgentMetrics(esClient: ElasticsearchClient, agents: Agent[]) {
try {
return await _fetchAndAssignAgentMetrics(esClient, agents);
Expand Down Expand Up @@ -112,6 +114,7 @@ const aggregationQueryBuilder = (agentIds: string[]) => ({
agents: {
terms: {
field: 'elastic_agent.id',
size: AGGREGATION_MAX_SIZE,
},
aggs: {
sum_memory_size: {
Expand All @@ -127,6 +130,7 @@ const aggregationQueryBuilder = (agentIds: string[]) => ({
processes: {
terms: {
field: 'elastic_agent.process',
size: AGGREGATION_MAX_SIZE,
order: {
_count: 'desc',
},
Expand Down

0 comments on commit 1499155

Please sign in to comment.