Guide · Amazon Forecast · Dataset Schema & Import

Amazon Forecast Dataset Import for MCP Servers — Schema Design, S3 CSV Format, and Timestamp Gotchas

Amazon Forecast requires structured time-series data uploaded to S3 before training begins. The schema design step is where most teams hit their first wall: attribute names must be lowercase, the timestamp format string must match your CSV exactly character-by-character, and missing time steps are silently skipped unless you configure fill transformations. This guide covers CreateDatasetCommand, the three dataset types (target time series, related time series, item metadata), S3 CSV formatting rules, CreateDatasetImportJobCommand params, and how to wire datasets into the dataset group.

TL;DR

Dataset types and when to use each

A Forecast dataset group supports up to three dataset types. Each type has different schema requirements and plays a different role in the model:

TARGET_TIME_SERIES (required)

The values you want Forecast to predict. Required columns: item_id (string), timestamp (timestamp), target_value (float). Every other column is a custom covariate. For MCP server monitoring:

Choose target_value as the metric that most directly represents what you want to predict — you cannot change it after the dataset is created without deleting and recreating the dataset.

RELATED_TIME_SERIES (optional)

Additional time series that co-vary with your target — these are covariates the model uses during training. Required columns: item_id (string), timestamp (timestamp), plus at least one additional float column. The related time series must:

For MCP monitoring, useful related time series include: upstream dependency error rates (if endpoint A's errors predict endpoint B's failures), deployment event flags (0 or 1 per hour), or external API quota consumption rates.

ITEM_METADATA (optional)

Static attributes per item — these don't vary over time. Required column: item_id (string), plus any string or float columns. Examples: endpoint category ("REST", "SSE", "stdio"), cloud provider, region, tier. Item metadata is included as categorical features and helps the model generalize across items with similar attributes.

Creating a dataset with CreateDatasetCommand

import { CreateDatasetCommand } from "@aws-sdk/client-forecast";

const { DatasetArn } = await forecast.send(new CreateDatasetCommand({
  DatasetName: "mcp-endpoint-requests",
  Domain: "CUSTOM",           // must match the dataset group's Domain
  DatasetType: "TARGET_TIME_SERIES",
  DataFrequency: "H",         // "Y"|"M"|"W"|"D"|"H"|"30min"|"15min"|"10min"|"5min"|"1min"
  Schema: {
    Attributes: [
      { AttributeName: "item_id",      AttributeType: "string" },
      { AttributeName: "timestamp",    AttributeType: "timestamp" },
      { AttributeName: "target_value", AttributeType: "float" },
      // Optional extra float covariate:
      // { AttributeName: "error_rate", AttributeType: "float" },
    ],
  },
  Tags: [{ Key: "project", Value: "alivemcp" }],
}));

console.log("Dataset ARN:", DatasetArn);

Schema attribute name rules

DataFrequency values

CodeIntervalTypical use
"1min"1 minuteHigh-frequency endpoint metrics
"5min"5 minutesMCP health check ping data
"H"1 hourRequest-per-hour traffic patterns
"D"1 dayDaily active user counts
"W"1 weekWeekly trend analysis

DataFrequency is immutable after dataset creation. If your data granularity changes, you must create a new dataset.

S3 CSV format

Forecast imports data from CSV files in S3. The required format:

Example CSV for the schema above (item_id, timestamp, target_value):

weather-mcp-prod,2026-01-01 00:00:00,142
weather-mcp-prod,2026-01-01 01:00:00,98
weather-mcp-prod,2026-01-01 02:00:00,67
maps-mcp-prod,2026-01-01 00:00:00,312
maps-mcp-prod,2026-01-01 01:00:00,289

Upload to S3 before creating the import job:

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { createReadStream } from "fs";

const s3 = new S3Client({ region: "us-east-1" });
await s3.send(new PutObjectCommand({
  Bucket: "my-forecast-data",
  Key: "mcp-endpoints/target-2026.csv",
  Body: createReadStream("./target-2026.csv"),
}));

Running CreateDatasetImportJobCommand

import { CreateDatasetImportJobCommand } from "@aws-sdk/client-forecast";

const { DatasetImportJobArn } = await forecast.send(new CreateDatasetImportJobCommand({
  DatasetImportJobName: "mcp-target-2026-import",
  DatasetArn,
  DataSource: {
    S3Config: {
      Path: "s3://my-forecast-data/mcp-endpoints/",   // S3 prefix — imports ALL objects here
      RoleArn: "arn:aws:iam::123456789012:role/ForecastS3ReadRole",
    },
  },
  TimestampFormat: "yyyy-MM-dd HH:mm:ss",
  // Other common formats:
  // "yyyy-MM-dd"              → "2026-01-15"
  // "yyyy-MM-dd'T'HH:mm:ss"  → "2026-01-15T14:00:00"
  // "MM/dd/yyyy HH:mm"        → "01/15/2026 14:00"
  ImportMode: "FULL",   // "FULL" replaces all data; "INCREMENTAL" appends new rows
  // TimeZone: "UTC",   // only needed if timestamps are local time, not UTC
}));

CRITICAL: TimestampFormat matching

The TimestampFormat string must match your CSV data character-for-character. The import job will return Status: "ACTIVE" even if zero rows were parsed — there is no row count in the success response. Always verify:

import { DescribeDatasetImportJobCommand } from "@aws-sdk/client-forecast";

// Poll until complete
let importJob;
while (true) {
  importJob = await forecast.send(new DescribeDatasetImportJobCommand({
    DatasetImportJobArn,
  }));
  if (importJob.Status === "ACTIVE" || importJob.Status === "CREATE_FAILED") break;
  await new Promise(r => setTimeout(r, 30_000));
}

if (importJob.Status === "CREATE_FAILED") {
  throw new Error(`Import failed: ${importJob.Message}`);
}

// CRITICAL: check that rows were actually imported
console.log("Data size:", importJob.DataSize);            // bytes imported
console.log("Field stats:", importJob.FieldStatistics);   // per-column stats

// If DataSize is 0 or FieldStatistics.target_value.Count is 0,
// your TimestampFormat doesn't match the CSV — no error thrown, just 0 rows.

The FieldStatistics map includes Count, Min, Max, and CountNan per column. If FieldStatistics.target_value.Count === 0, the entire import silently failed due to format mismatch.

Common TimestampFormat mistakes

CSV data exampleCorrect formatCommon mistake
2026-01-15 14:00:00yyyy-MM-dd HH:mm:ssyyyy-MM-dd HH:mm (missing :ss)
2026-01-15yyyy-MM-ddyyyy/MM/dd (wrong separator)
2026-01-15T14:00:00yyyy-MM-dd'T'HH:mm:ssyyyy-MM-dd HH:mm:ss (space vs T)
01/15/2026 14:00MM/dd/yyyy HH:mmdd/MM/yyyy HH:mm (day/month order)

IAM role for S3 access

The RoleArn in S3Config must be assumable by the Forecast service and have S3 read permissions:

// Trust policy (allow Forecast service to assume this role)
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "Service": "forecast.amazonaws.com" },
    "Action": "sts:AssumeRole"
  }]
}

// Permission policy
{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": ["s3:GetObject", "s3:ListBucket"],
    "Resource": [
      "arn:aws:s3:::my-forecast-data",
      "arn:aws:s3:::my-forecast-data/*"
    ]
  }]
}

For export jobs (CreateForecastExportJobCommand), the same role also needs s3:PutObject.

Wiring datasets into the dataset group

Creating a dataset does not automatically associate it with a dataset group. You must either pass DatasetArns at dataset group creation time, or update the group afterward:

import { UpdateDatasetGroupCommand } from "@aws-sdk/client-forecast";

// Add all datasets to the group at once — this replaces the full list
await forecast.send(new UpdateDatasetGroupCommand({
  DatasetGroupArn,
  DatasetArns: [
    targetDatasetArn,
    relatedDatasetArn,   // optional
    metadataDatasetArn,  // optional
  ],
}));

The predictor training stage references only the DatasetGroupArn — it discovers all associated datasets automatically. If you forget to wire a dataset into the group, the predictor trains without it and you won't get an error — it just trains on less data.

INCREMENTAL imports and re-training

To append new rows without replacing existing data, use ImportMode: "INCREMENTAL":

await forecast.send(new CreateDatasetImportJobCommand({
  DatasetImportJobName: `mcp-target-${Date.now()}-incremental`,
  DatasetArn,
  DataSource: {
    S3Config: {
      Path: "s3://my-forecast-data/mcp-endpoints/incremental/",
      RoleArn,
    },
  },
  TimestampFormat: "yyyy-MM-dd HH:mm:ss",
  ImportMode: "INCREMENTAL",
}));

Incremental imports update the dataset, but existing predictors do not automatically retrain on the new data. After an incremental import, you must create a new predictor (or use RetrainingFrequency on an AutoPredictor) to incorporate the new data into forecasts.

Automatic retraining with AutoPredictor

The CreateAutoMLPredictorCommand supports a DataConfig.AdditionalDatasets parameter where you configure automatic retraining frequency so that incremental imports trigger model updates on a schedule rather than requiring manual predictor recreation. This is covered in the predictor training guide.

Continue in this series

Related guides: S3 for MCP server storage · IAM roles for MCP servers