apache/skywalking · error · IllegalArgumentException
Can't find metrics, {}
Error message
Can't find metrics, {} What it means
Thrown by MetricsHolder.find(functionName) during OAL script analysis when the aggregation function used in an OAL rule is not registered. MetricsHolder lazily scans and registers all classes implementing the Metrics aggregator interface (discovered via SPI/service files) into a REGISTER map keyed by function name. A null lookup means no registered aggregator answers to that function name.
Source
Thrown at oap-server/oal-rt/src/main/java/org/apache/skywalking/oal/v2/metadata/MetricsHolder.java:60
MetricsFunction metricsFunction = aClass.getAnnotation(MetricsFunction.class);
REGISTER.put(
metricsFunction.functionName(),
(Class<? extends Metrics>) aClass
);
}
}
}
@SneakyThrows
public static Class<? extends Metrics> find(String functionName) {
if (!INITIALIZED) {
init();
INITIALIZED = true;
}
Class<? extends Metrics> metricsClass = REGISTER.get(functionName);
if (metricsClass == null) {
throw new IllegalArgumentException("Can't find metrics, " + functionName);
}
return metricsClass;
}
}
View on GitHub (pinned to 102af09b4a)
Solutions
- Check the supported function list in the OAL docs (docs/en/concepts-and-designs/oal.md) and correct the function name in the .oal file
- If you intended a custom function, implement the Metrics class and register it via META-INF/services so MetricsHolder.init() picks it up, then rebuild
- Verify the exact spelling/case of the registered key by inspecting the registered Metrics implementations' name() methods
Example fix
// before (OAL) service_resp_time = from ServiceSpan.sum(duration) --> no; wrong usage endpoint_avg = from Endpoint.latency.longAvg() --> endpointAvg // after: use a registered function name endpoint_avg = from Endpoint.latency.avg() --> endpointAvg
Defensive patterns
Strategy: validation
Validate before calling
// Lint OAL function names against the registry before deploy:
Set<String> valid = Arrays.stream(metricsImplementations).map(m -> m.name()).collect(toSet());
if (!valid.contains(oalFunctionName)) fail("Unknown OAL function: " + oalFunctionName); Try / catch
Catch IllegalArgumentException around OALScriptParserV2 / MetricsHolder usage in tooling (CLI lint, dsl-debugging install) and surface the message; in OAP startup, let it fail fast — an OAL rule with an unknown function cannot work.
Prevention
- Validate new OAL rules in a staging OAP or via the dsl-debugging API before applying them through dynamic configuration
- For custom aggregators, add an SPI registration test that fails the build if the function name is not resolvable via MetricsHolder.find()
When it happens
Trigger: An OAL script uses an aggregation function that does not exist, e.g. 'percentile90(...)' or 'median(...)' when only registered names like 'longAvg', 'avg', 'sum', 'percentile' are available; or a custom Metrics implementation was written but its service-file entry in META-INF/services is missing; or the function name case does not match the registered key.
Common situations: Writing new OAL rules with a guessed function name; upgrading SkyWalking where function names changed; adding a custom aggregator without SPI registration; typo in the OAL rule (e.g. 'longAVG' vs 'longAvg').
Related errors
- filter expression [{}] not found
- Unknown filter value type: {}
- Unsupported filter: {}
- castType:{castType} is legal, context expression:{originalEx
- LALSourceTypeProvider {} for layer {} declared inputType {}
AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14).
Data as JSON: /api/errors/757d98da14c67c00.
Report an issue: GitHub.