elastic/elasticsearch · error · IllegalArgumentException

Cannot create past TSDB backing index for data stream [{}] w

Error message

Cannot create past TSDB backing index for data stream [{}] with mode [{}], it needs to be a time series data stream.

What it means

Thrown by validateDataStream in the past-TSDB-backing-index creation action when the targeted data stream's index mode is not 'time_series'. The API exists only to create time series (TSDB) backing indices that pre-date the stream's first index, so a non-TSDB stream is an argument error (IllegalArgumentException). The message reports the actual mode so the caller can see the mismatch.

Source

Thrown at modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportPastTimeSeriesIndexCreationAction.java:529

        CoveredTimeWindow(Instant start, Instant end) {
            this(start.toEpochMilli(), end.toEpochMilli());
        }
    }

    private static void validateDataStream(String dataStreamName, DataStream dataStream, ProjectMetadata project) {
        if (dataStream == null) {
            throw new ResourceNotFoundException("Data stream [" + dataStreamName + "] not found");
        }
        if (dataStream.isReplicated()) {
            throw new IllegalArgumentException("Cannot create past TSDB backing index for replicated data stream [" + dataStreamName + "]");
        }
        if (dataStream.isSystem()) {
            throw new IllegalArgumentException("Cannot create past TSDB backing index for system data stream [" + dataStreamName + "]");
        }

        if (IndexMode.isTsdb(dataStream.getIndexMode()) == false) {
            throw new IllegalArgumentException(
                "Cannot create past TSDB backing index for data stream ["
                    + dataStreamName
                    + "] with mode ["
                    + dataStream.getIndexMode()
                    + "], it needs to be a time series data stream."
            );
        }
        Index writeIndex = dataStream.getWriteIndex();
        IndexMetadata writeIndexMetadata = writeIndex == null ? null : project.index(writeIndex);
        if (writeIndexMetadata == null || IndexMode.isTsdb(writeIndexMetadata.getIndexMode()) == false) {
            throw new IllegalStateException(
                "Cannot create past TSDB backing index for data stream ["
                    + dataStreamName
                    + "] because it requires to have yet at least one time series backing index. Please rollover first."
            );
        }
    }

View on GitHub (pinned to db6a809a66)

Solutions

  1. Verify the mode with GET _data_stream/<name> and confirm index.mode is time_series
  2. Create a new data stream backed by a composable index template that sets index.mode: time_series (and the required time_series dimensions/mappings)
  3. Reindex or re-ingest the data into the correctly configured TSDB data stream, then retry the past-index creation against it

Example fix

// before
PUT _index_template/my-template
{ "template": { "settings": {} }, ... } // missing index.mode
// after
PUT _index_template/my-template
{ "template": { "settings": { "index.mode": "time_series", "index.routing_path": ["host"] } }, ... }
Defensive patterns

Strategy: validation

Validate before calling

// Before calling the past-TSDB-index API, confirm the stream is TSDB:
// GET _data_stream/<name> -> check index.mode == 'time_series'
String mode = getDataStreamIndexMode(name);
if (!"time_series".equals(mode)) {
    throw new IllegalStateException("Cannot create past TSDB index: stream mode is " + mode);
}

Prevention

When it happens

Trigger: Calling the past TSDB index creation transport action (TransportPastTimeSeriesIndexCreationAction) for a data stream whose DataStream#indexMode returns anything other than a TSDB mode (e.g. STANDARD, LOGSDB, LOGS). The check IndexMode.isTsdb(dataStream.getIndexMode()) == false fires before any backing index is built.

Common situations: Index template omitted 'index.mode: time_series' so the stream was created as a standard/logs data stream; calling the API against a logs data stream by mistake; migrating from a standard stream without recreating it as TSDB; copy/paste of the wrong data stream name.

Related errors


AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12). Data as JSON: /api/errors/9df96bd14cb37ce8. Report an issue: GitHub.