apache/skywalking · error · IllegalArgumentException

Unsupported extractor statement in LAL rule at line {sourceL

Error message

Unsupported extractor statement in LAL rule at line {sourceLine}: {sourceText}

What it means

Thrown by MeterEntity.id() when the entity's scopeType is not one of the seven meter-supported scopes handled in the switch: SERVICE, SERVICE_INSTANCE, ENDPOINT, PROCESS, SERVICE_RELATION, PROCESS_RELATION, SERVICE_INSTANCE_RELATION. MeterEntity must translate its scope into an IDManager-built entity id; scope types with no id-building rule (e.g. SERVICE_INSTANCE_CLONE or future enum constants) cannot produce an id.

Source

Thrown at oap-server/analyzer/log-analyzer/src/main/java/org/apache/skywalking/oap/log/analyzer/v2/compiler/LALScriptParser.java:273

            return visitTagStatement(ctx.tagStatement()).withSource(sourceLine, sourceText);
        }
        if (ctx.metricsBlock() != null) {
            return visitMetricsBlock(ctx.metricsBlock()).withSource(sourceLine, sourceText);
        }
        if (ctx.outputFieldStatement() != null) {
            return visitOutputFieldStatement(ctx.outputFieldStatement())
                .withSource(sourceLine, sourceText);
        }
        // ifStatement carries its own per-branch line info; surface the if-line
        // here for the surrounding statement-level capture.
        if (ctx.ifStatement() != null) {
            return (ExtractorStatement) visitIfStatement(ctx.ifStatement());
        }
        // Every alternative in the grammar's extractorStatement rule must have a branch above.
        // Falling through used to run visitIfStatement(null), which threw a NullPointerException
        // naming IfStatementContext — for a rule line containing no `if`, telling the author
        // nothing. That is how segmentId and spanId stayed unimplemented without anyone noticing.
        throw new IllegalArgumentException(
            "Unsupported extractor statement in LAL rule at line " + sourceLine + ": " + sourceText);
    }

    /**
     * Verbatim source text of an ANTLR rule context — pulls from the original
     * input stream rather than re-concatenating tokens, so whitespace inside
     * the statement is preserved (matters for the dsl-debugging UI rendering
     * {@code "line N: <verbatim>"}).
     */
    private static String rawTextOf(final ParserRuleContext ctx) {
        if (ctx.getStart() == null || ctx.getStop() == null) {
            return "";
        }
        return ctx.getStart().getInputStream().getText(
            Interval.of(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex()));
    }

    private static FieldAssignment visitFieldAssignment(

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Create MeterEntity through its factory methods (newService, newServiceInstance, newEndpoint, newProcess, relation variants) so scopeType and fields stay consistent
  2. Restrict MAL metric scope declarations to the supported scope types
  3. If you added a ScopeType, add the corresponding IDManager case to MeterEntity.id()
Defensive patterns

Strategy: validation

Validate before calling

java.util.Set<ScopeType> METER_SCOPES = java.util.EnumSet.of(ScopeType.SERVICE, ScopeType.SERVICE_INSTANCE,
    ScopeType.ENDPOINT, ScopeType.PROCESS, ScopeType.SERVICE_RELATION,
    ScopeType.PROCESS_RELATION, ScopeType.SERVICE_INSTANCE_RELATION);
if (!METER_SCOPES.contains(entity.getScopeType())) throw new IllegalArgumentException("unsupported meter scope");

Prevention

When it happens

Trigger: Building a MeterEntity via newService/... factory then calling id() after manually setting an unsupported scope type; a MAL rule declaring a metric on a scope the meter system cannot address, routed into MeterEntity.id().

Common situations: Writing a custom MAL function or meter receiver that constructs MeterEntity for an unsupported ScopeType; extending ScopeType with new constants without extending MeterEntity.id(); reflective mutation of the private scopeType field.

Related errors


AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14). Data as JSON: /api/errors/d86e2f4b277e06b3. Report an issue: GitHub.