**Build scan:**
https://gradle-enterprise.elastic.co/s/xl4uqehihgkxs/tests/:x-pack:plugin:rollup:test/org.elasticsearch.xpack.rollup.v2.RollupActionSingleNodeTests/testRollupDatastream

**Reproduction line:**
`./gradlew ':x-pack:plugin:rollup:test' --tests "org.elasticsearch.xpack.rollup.v2.RollupActionSingleNodeTests.testRollupDatastream" -Dtests.seed=4E779F8B2A344C56 -Dtests.locale=sl -Dtests.timezone=NST -Druntime.java=18`

**Applicable branches:**
main

**Reproduces locally?:**
No

**Failure history:**
https://gradle-enterprise.elastic.co/scans/tests?tests.container=org.elasticsearch.xpack.rollup.v2.RollupActionSingleNodeTests&tests.test=testRollupDatastream

**Failure excerpt:**
```
org.elasticsearch.action.search.SearchPhaseExecutionException: 
  at __randomizedtesting.SeedInfo.seed([4E779F8B2A344C56:84AC3906E3AE0A19]:0)
  at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:728)
  at org.elasticsearch.action.search.FetchSearchPhase$1.onFailure(FetchSearchPhase.java:95)
  at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:28)
  at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
  at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769)
  at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
  at java.lang.Thread.run(Thread.java:833)

  Caused by: org.elasticsearch.search.aggregations.MultiBucketConsumerService$TooManyBucketsException: Trying to create too many buckets. Must be less than or equal to: [65536] but this number of buckets was exceeded. This limit can be set by changing the [search.max_buckets] cluster level setting.

    at org.elasticsearch.search.aggregations.MultiBucketConsumerService$MultiBucketConsumer.accept(MultiBucketConsumerService.java:115)
    at org.elasticsearch.search.aggregations.AggregationReduceContext$ForFinal.consumeBucketCountAndMaybeBreak(AggregationReduceContext.java:213)
    at org.elasticsearch.search.aggregations.AggregationReduceContext.consumeBucketsAndMaybeBreak(AggregationReduceContext.java:119)
    at org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram.addEmptyBuckets(InternalDateHistogram.java:407)
    at org.elasticsearch.search.aggregations.bucket.histogram.InternalDateHistogram.reduce(InternalDateHistogram.java:476)
    at org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:159)
    at org.elasticsearch.search.aggregations.bucket.terms.AbstractInternalTerms.reduceBucket(AbstractInternalTerms.java:109)
    at org.elasticsearch.search.aggregations.DelayedBucket.reduced(DelayedBucket.java:59)
    at org.elasticsearch.search.aggregations.TopBucketBuilder$BufferingTopBucketBuilder.build(TopBucketBuilder.java:180)
    at org.elasticsearch.search.aggregations.bucket.terms.AbstractInternalTerms.reduce(AbstractInternalTerms.java:315)
    at org.elasticsearch.search.aggregations.InternalAggregations.reduce(InternalAggregations.java:159)
    at org.elasticsearch.search.aggregations.InternalAggregations.topLevelReduce(InternalAggregations.java:106)
    at org.elasticsearch.action.search.SearchPhaseController.reduceAggs(SearchPhaseController.java:601)
    at org.elasticsearch.action.search.SearchPhaseController.reducedQueryPhase(SearchPhaseController.java:570)
    at org.elasticsearch.action.search.QueryPhaseResultConsumer.reduce(QueryPhaseResultConsumer.java:130)
    at org.elasticsearch.action.search.FetchSearchPhase.innerRun(FetchSearchPhase.java:104)
    at org.elasticsearch.action.search.FetchSearchPhase$1.doRun(FetchSearchPhase.java:90)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:33)
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.lang.Thread.run(Thread.java:833)

```
x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java
client().admin()
            .indices()
            .prepareCreate(sourceIndex)
            .setSettings(
                Settings.builder()
                    .put("index.number_of_shards", numOfShards)
                    .put("index.number_of_replicas", numOfReplicas)
                    .put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES)
                    .putList(IndexMetadata.INDEX_ROUTING_PATH.getKey(), List.of(FIELD_DIMENSION_1))
                    .put(IndexSettings.TIME_SERIES_START_TIME.getKey(), Instant.ofEpochMilli(startTime).toString())
                    .put(IndexSettings.TIME_SERIES_END_TIME.getKey(), "2106-01-08T23:40:53.384Z")
                    .build()
            )
            .setMapping(
                FIELD_TIMESTAMP,
                "type=date",
                FIELD_DIMENSION_1,
                "type=keyword,time_series_dimension=true",
                FIELD_DIMENSION_2,
                "type=long,time_series_dimension=true"
            )
            .get();
        RollupActionConfig config = new RollupActionConfig(randomInterval());
        prepareSourceIndex(sourceIndex);
        Exception exception = expectThrows(RollupActionRequestValidationException.class, () -> rollup(sourceIndex, rollupIndex, config));
        assertThat(exception.getMessage(), containsString("does not contain any metric fields"));
    }
    public void testCannotRollupWriteableIndex() {
        RollupActionConfig config = new RollupActionConfig(randomInterval());