apache/skywalking · error · IllegalStateException

Current time bucket is not in minute dimensionality

Error message

Current time bucket is not in minute dimensionality

What it means

Metrics.toTimeBucketInHour() converts a minute-dimensionality time bucket (yyyyMMddHHmm) to the hour bucket by dividing by 100. It only supports minute buckets; if the metric's timeBucket is hour, day, or second dimensional, isMinuteBucket() is false and this IllegalStateException is thrown (the message text 'not in minute dimensionality' is slightly misleading — it means the bucket is NOT minute).

Source

Thrown at oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/metrics/Metrics.java:111

     */
    public void setLastUpdateTimestamp(long timestamp) {
        lastUpdateTimestamp = timestamp;
    }

    /**
     * @param timestamp        of current time
     * @param expiredThreshold represents the duration between last update time and the time point removing from cache.
     * @return true means this metrics should be removed from cache.
     */
    public boolean isExpired(long timestamp, long expiredThreshold) {
        return timestamp - lastUpdateTimestamp > expiredThreshold;
    }

    public long toTimeBucketInHour() {
        if (isMinuteBucket()) {
            return timeBucket / 100;
        } else {
            throw new IllegalStateException("Current time bucket is not in minute dimensionality");
        }
    }

    public long toTimeBucketInDay() {
        if (isMinuteBucket()) {
            return timeBucket / 10000;
        } else if (isHourBucket()) {
            return timeBucket / 100;
        } else {
            throw new IllegalStateException("Current time bucket is not in minute dimensionality");
        }
    }

    /**
     * Always get the duration for this time bucket in minute.
     */
    protected long getDurationInMinute() {
        if (isMinuteBucket()) {

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Ensure the metric is built on a minute time bucket (DownSampling.Minute) before calling toTimeBucketInHour(), or compute the hour bucket directly
  2. In custom metrics code, guard with a TimeBucket.isMinuteBucket(timeBucket) check and skip/convert appropriately
  3. Audit custom MetricFunction implementations added to the classpath for unsupported bucket conversions

Example fix

// before
long hourBucket = metrics.toTimeBucketInHour();
// after (only convert when source is minute-granularity)
long hourBucket = TimeBucket.isMinuteBucket(timeBucket) ? timeBucket / 100 : timeBucket;
Defensive patterns

Strategy: type-guard

Type guard

// Java: check granularity before converting
boolean isMinuteBucket(long tb) {
    return TimeBucket.isMinuteBucket(tb); // yyyyMMddHHmm, 12 digits
}
// usage
long hourBucket = isMinuteBucket(metrics.getTimeBucket()) ? metrics.toTimeBucketInHour() : metrics.getTimeBucket();

Try / catch

Not recommended — prefer the granularity guard; if unavoidable, catch IllegalStateException and fall back to the raw timeBucket with a loud WARN.

Prevention

When it happens

Trigger: A custom Metrics subclass or a meter function calls toTimeBucketInHour() on a metric whose timeBucket was set with TimeBucket.getTimeBucket(System.currentTimeMillis(), DownSampling.Hour) or any non-minute downsampling.

Common situations: Writing a custom OAL/MAL metrics function that reuses hour-level downsampling but inherits the minute-only conversion; changing a metric's DownSampling annotation from Minute to Hour while keeping the hour-conversion call.

Related errors


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