alibaba/Sentinel · error · IllegalArgumentException

Interval cannot be less than 1

Error message

Interval cannot be less than 1

What it means

StatLoggerBuilder.validateInterval rejects flush intervals below 1 second. EagleEye stat loggers aggregate and flush on a fixed whole-second interval (converted to intervalMillis = intervalSeconds * 1000), so zero or negative intervals have no valid meaning and throw IllegalArgumentException. Note the message concatenates the value without a separator ("Interval cannot be less than 1" + intervalSeconds).

Source

Thrown at sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/StatLoggerBuilder.java:97

        EagleEyeAppender appender = this.appender;
        if (appender == null) {
            EagleEyeRollingFileAppender rfAppender = new EagleEyeRollingFileAppender(filePath, maxFileSize);
            appender = new SyncAppender(rfAppender);
        }

        EagleEyeLogDaemon.watch(appender);
        return new StatLogger(loggerName, appender, intervalMillis, maxEntryCount,
            entryDelimiter, keyDelimiter, valueDelimiter);
    }

    public StatLogger buildSingleton() {
        return StatLogController.createLoggerIfNotExists(this);
    }

    static void validateInterval(final long intervalSeconds) throws IllegalArgumentException {
        if (intervalSeconds < 1) {
            throw new IllegalArgumentException("Interval cannot be less than 1" + intervalSeconds);
        } else if (intervalSeconds < 60) {
            if (60 % intervalSeconds != 0) {
                throw new IllegalArgumentException("Invalid second interval (cannot divide by 60): " + intervalSeconds);
            }
        } else if (intervalSeconds <= 5 * 60) {
            if (intervalSeconds % 60 != 0) {
                throw new IllegalArgumentException("Invalid second interval (cannot divide by 60): " + intervalSeconds);
            }
            if (60 % intervalSeconds != 0) {
                throw new IllegalArgumentException("Invalid second interval (cannot divide by 60): " + intervalSeconds);
            }
        } else if (intervalSeconds > 5 * 60) {
            throw new IllegalArgumentException("Interval should be less than 5 min: " + intervalSeconds);
        }
    }
}

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Pass a whole-second interval between 1 and 300 that divides 60 (e.g. 1, 2, 5, 10, 60).
  2. Check the unit of the configured value; convert milliseconds to seconds before calling the builder.
  3. Validate interval config at startup against the same rules validateInterval enforces.

Example fix

// before
int interval = config.getInt("stat.flush.ms", 0); // ms, API wants seconds
builder.intervalSeconds(interval); // throws

// after
int intervalMs = config.getInt("stat.flush.ms", 1000);
int intervalSec = Math.max(1, intervalMs / 1000);
builder.intervalSeconds(intervalSec);
Defensive patterns

Strategy: validation

Validate before calling

long sec = intervalMillis / 1000;
if (sec < 1 || sec > 60) { throw new IllegalArgumentException("interval out of range: " + sec); }
builder.intervalSeconds((int) sec);

Prevention

When it happens

Trigger: Calling intervalSeconds(0) or a negative number on the builder — typically an interval loaded from config that is unset, defaults to 0, or is computed (e.g. ms vs s unit confusion: passing 500 meaning milliseconds).

Common situations: Configuration expresses the interval in milliseconds but the API takes seconds, so 500ms becomes 500s or a 0 slips through. A new environment omits the interval property and the fallback is 0. Refactoring changes the default from a valid value to 0.

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/5b62d72773520959. Report an issue: GitHub.