pinpoint-apm/pinpoint · error · IllegalArgumentException

agentIds size exceeds max limit. size: <agentIds.size()>, ma

Error message

agentIds size exceeds max limit. size: <agentIds.size()>, max: <MAX_AGENT_IDS>

What it means

DefaultAgentStatService.selectAgentStatGroupedByAgentId throws IllegalArgumentException when the caller passes more than MAX_AGENT_IDS agent IDs in a single inspector metric query. The batched per-field query strategy fans out into collectors per agent, so an oversized agentId list would produce an unbounded query and result set; the service rejects it up front.

Source

Thrown at inspector-module/inspector-web/src/main/java/com/navercorp/pinpoint/inspector/web/service/DefaultAgentStatService.java:222

        }

        return invokeList;
    }

    private QueryResult selectOneField(InspectorDataSearchKey inspectorDataSearchKey, MetricDefinition metricDefinition) {
        Field field = metricDefinition.getFields().stream().findFirst().get();
        CompletableFuture<List<DataPoint<Double>>> doubleFuture = agentStatDao.selectAgentStat(inspectorDataSearchKey, metricDefinition.getMetricName(), field);
        return new QueryResult(doubleFuture, field);
    }


    @Override
    public InspectorMetricGroupData selectAgentStatGroupedByAgentId(
            String tenantId, String serviceName, String applicationName, List<String> agentIds,
            String metricDefinitionId, TimeWindow timeWindow) {

        if (agentIds.size() > MAX_AGENT_IDS) {
            throw new IllegalArgumentException("agentIds size exceeds max limit. size: " + agentIds.size() + ", max: " + MAX_AGENT_IDS);
        }

        MetricDefinition metricDefinition = ymlInspectorManager.findElementOfBasicGroup(metricDefinitionId);

        // One query per field (M queries) instead of N×M queries
        List<BatchQueryResult> batchResults = selectAllByAgentIds(tenantId, serviceName, applicationName, agentIds, metricDefinition, timeWindow);

        CompletableFuture<?>[] allFutures = batchResults.stream()
                .map(BatchQueryResult::future)
                .toArray(CompletableFuture[]::new);

        try {
            CompletableFuture.allOf(allFutures).get();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e.getCause());

View on GitHub (pinned to 744c3d3075)

Solutions

  1. Reduce the number of agentIds per request below MAX_AGENT_IDS (split into batches or paginate in the UI).
  2. Filter agentIds by selected host/agent subset before calling selectAgentStatGroupedByAgentId.
  3. Check MAX_AGENT_IDS in DefaultAgentStatService and, if genuinely needed, raise it consciously after assessing collector/storage load.
  4. Catch IllegalArgumentException and surface a clear 'too many agents selected' message to the user.

Example fix

// before
List<String> agentIds = loadAllAgentIds(applicationName);
inspectorStatService.selectAgentStatGroupedByAgentId(tenantId, serviceName, applicationName, agentIds, metricDefinitionId, timeWindow);

// after
List<String> agentIds = loadAllAgentIds(applicationName);
for (List<String> batch : Lists.partition(agentIds, MAX_AGENT_IDS)) {
    inspectorStatService.selectAgentStatGroupedByAgentId(tenantId, serviceName, applicationName, batch, metricDefinitionId, timeWindow);
}
Defensive patterns

Strategy: validation

Validate before calling

if (agentIds.size() > MAX_AGENT_IDS) {
    throw new IllegalArgumentException("agentIds size exceeds max limit. size: " + agentIds.size() + ", max: " + MAX_AGENT_IDS);
}

Try / catch

try {
    data = service.selectAgentStatGroupedByAgentId(tenantId, serviceName, app, agentIds, metricDefId, timeWindow);
} catch (IllegalArgumentException e) {
    // fall back to batching
}

Prevention

When it happens

Trigger: Calling InspectorMetricController/service endpoints like /getAgentStatGroupedByAgentId with an agentIds parameter containing more than MAX_AGENT_IDS entries (e.g. selecting all agents of a very large application in one request).

Common situations: UI dashboards that select an entire application without pagination; scripted API calls that pass every agent ID of a large cluster; integration code that builds agentIds from a filtered-but-unbounded list after an agent count grew over time.

Related errors


AI-assisted analysis of pinpoint-apm/pinpoint@744c3d3075 (2026-09-07). Data as JSON: /api/errors/68a1e32994951c93. Report an issue: GitHub.