Try it free

Import archives into Grail

  • Latest Dynatrace
  • How-to guide
  • 8-min read
  • Published Nov 13, 2026

Preview

Preview

Archive import is available as part of a Preview. Preview features give you early access so we can shape the final design around real-world usage—they're not intended for production environments, and behavior, configuration options, and supported integrations may change before general availability.

We want to hear from you: What works well? Where do you hit friction in the import workflow? Which cloud providers or storage types—Azure Blob Storage, Google Cloud Storage, other S3-compatible systems—matter most for your use cases? Your feedback directly influences what we build next.

Preview features aren't publicly available—you need to sign up for the corresponding Preview. For more information about conditions and how to sign up, see Preview program.

Archive import reads NDJSON log files from your existing cloud object storage and ingests them into a dedicated Grail bucket, preserving the original timestamps. Your data stays in your cloud account; Dynatrace copies each record into Grail where it becomes queryable with plain DQL alongside your live data.

Currently, only AWS S3 buckets are supported as archive sources.

Prerequisites

To create and manage archive import jobs, the following Dynatrace policies are required:

ALLOW storage:jobs:read;
ALLOW storage:jobs:write;
ALLOW storage:external-datastore-definitions:read;

In addition:

  • External datastore — the source S3 bucket must already be connected as an External Data Store. The externalDataStoreName you use in job requests is the label you assigned when setting up the connection.
  • Destination bucket — a Grail bucket of type logs with the historical flag set must already exist to receive the imported records.

Prepare your archive

Before importing, make sure your archive meets the following requirements:

  • Format: NDJSON—one JSON log record per line.
  • Compression: gzip (.gz) is supported; uncompressed files are also accepted.
  • File size: each file must be smaller than 16 MB, whether compressed or uncompressed.
  • Time span per file: all records within a single file must span no more than 96 hours.
  • Date in path Recommended: encoding the date in the file path—for example, 2024/01/15/—lets the API filter files by date range before reading them. See Date filtering.

Import archives

The base URL for all Jobs API endpoints is:

https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1

Access API documentation

To access the Swagger API documentation for the Grail Storage Jobs API and to start making API requests using Swagger:

  1. Search for and select Dynatrace API.

  2. In the Select a definition field, select Grail - Storage Jobs.

  3. Optional Authenticate with your API token if you want to use Swagger to execute your requests. For more details, see Authentication. Select Try it out to interact with the API directly from the documentation.

  4. Perform one of the following actions.

    To do thisSelect this
    Check which files a prefix matches, and whether their date layout is recognized, without writing records.POST/platform/storage/jobs/v1/jobs/import:preview
    Submit an import job for files that match your prefix and date range.POST/platform/storage/jobs/v1/jobs/import:execute
    List the import jobs in your environment.GET/platform/storage/jobs/v1/jobs
    Track a job's state and the number of files it has processed.GET/platform/storage/jobs/v1/jobs/{job-id}
    Review each attempt made for a job, with its own metrics.GET/platform/storage/jobs/v1/jobs/{job-id}/executions
    Inspect the individual files of a job, optionally filtered by state.GET/platform/storage/jobs/v1/jobs/{job-id}/items
    Stop a job that is still pending or running.POST/platform/storage/jobs/v1/jobs:cancel
    Re-run a failed job, reprocessing only the files that have not succeeded.POST/platform/storage/jobs/v1/jobs:retry

Step 1: Preview import

Use the preview endpoint to check that your prefix matches the files you expect and that their date layout is recognized before submitting a job. No records are written.

Preview returns a small sample rather than scanning the whole archive, so it is a validation step, not a sizing tool. To size an archive, measure it at the source.

POST /jobs/import:preview
FieldRequiredDescription
externalDataStoreNameYesLabel of the source S3 connection.
prefixYesPath prefix to scope which files are included. Must start with /. Use / for all files, or a path such as /application-logs to narrow the selection. You can also state the date layout explicitly, for example /application-logs/<yyyy>/<MM>/<dd>/<HH>/*.
startDateNoInclude only files whose path-encoded date is on or after this date. ISO 8601 format.
endDateNoInclude only files whose path-encoded date is before this date (exclusive). ISO 8601 format.
curl -X POST \
"https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs/import:preview" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"externalDataStoreName": "prod-s3-archive",
"prefix": "/application-logs",
"startDate": "2020-01-10T00:00:00Z",
"endDate": "2020-01-23T00:00:00Z"
}'

Response—200 OK

{
"size": "26412",
"timePattern": "/application-logs/<yyyy>/<MM>/<dd>/<HH>/**",
"fileLimitHit": true,
"timeLimitHit": false,
"metadata": {
"warnings": []
},
"samples": [
{
"name": "chunk-01dc1b13.ndjson.gz",
"path": "cloud://prod-s3-archive/application-logs/2020/01/10/00/chunk-01dc1b13.ndjson.gz",
"size": "2595",
"fileTime": "2020-01-10T00:00:00Z"
}
]
}
FieldDescription
timePatternThe date layout resolved from the file paths, for example /application-logs/<yyyy>/<MM>/<dd>/<HH>/**. If it comes back as your prefix followed by /**, no layout was resolved. For more information, see Date filtering.
samplesA small set of example matching files, each with name, path (a cloud:// URI), size, and fileTime—the timestamp parsed from the path.
sizeTotal bytes of the sampled files only—not the size of the archive, and not an estimate of what an import would read.
fileLimitHittrue when more files match than the sample cap allows. This is the normal result for any sizeable archive.
timeLimitHittrue when sampling stopped at the 30-second limit. The sample is then representative rather than complete—widen or pair your date bounds and try again.
metadata.warningsConditions worth knowing about in an otherwise successful response, each with a stable code and a human-readable message. Check the code; the wording can change. NO_FILES_FOUND means nothing matched your prefix. TIME_RANGE_IGNORED means no date layout was resolved, so startDate and endDate were not applied and every file under the prefix would be imported.

A preview can succeed and still not have done what you asked. Check metadata.warnings first:

"metadata": {
"warnings": [
{
"code": "TIME_RANGE_IGNORED",
"message": "No time pattern was detected under '/application-logs', so startDate and endDate were ignored and all files are imported."
}
]
}

TIME_RANGE_IGNORED means your date window was dropped; NO_FILES_FOUND means the prefix matched nothing—check it for a typo, such as a doubled /. In both cases timePattern comes back as your prefix followed by /** and the samples carry no fileTime. Re-issue the call with the layout stated explicitly, for example /application-logs/<yyyy>/<MM>/<dd>/<HH>/*.

Step 2: Execute import

Once you're satisfied with the preview, submit the import job. The same request body as the preview applies, with the addition of bucketName.

POST /jobs/import:execute
FieldRequiredDescription
externalDataStoreNameYesLabel of the source S3 connection.
bucketNameYesName of the destination Grail bucket where records will be written.
prefixYesPath prefix. Same format as for preview.
startDateNoStart of the date range (inclusive). ISO 8601 format.
endDateNoEnd of the date range (exclusive). ISO 8601 format.
curl -X POST \
"https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs/import:execute" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"externalDataStoreName": "prod-s3-archive",
"bucketName": "my-archive-bucket",
"prefix": "/application-logs",
"startDate": "2020-01-10T00:00:00Z",
"endDate": "2020-01-23T00:00:00Z"
}'

Response—202 Accepted

{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}

Use the returned id to monitor and manage the job. Records are available in Grail as they're ingested, even while the job is still running.

Error responses

CodeDescription
400Request body failed validation—for example, endDate is not later than startDate—the referenced bucket or external datastore does not exist or is not usable, or the tenant is not active.
401Missing or invalid authentication credentials.
403A required permission is missing.
503The tenant's active state could not be determined. Retryable.

Monitor and manage jobs

Monitor job progress

Poll this endpoint to track how many files have been processed.

GET /jobs/{id}
curl "https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890" \
-H "Authorization: Bearer <token>"

Response—200 OK

{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "IMPORT",
"state": "RUNNING",
"createTime": "2024-03-12T09:00:00Z",
"finishTime": null,
"createdBy": {
"id": "…",
"email": "jane.doe@example.com"
},
"details": {
"type": "IMPORT",
"metrics": {
"totalItems": "1500",
"totalBytes": "3145728000",
"processedItems": "430",
"processedBytes": "901775360",
"failedItems": "0"
}
}
}
FieldDescription
statePENDING—queued, not yet started. RUNNING—actively processing files. SUCCEEDED—all files completed. FAILED—the job stopped before completing; it can be retried. CANCELLED—stopped before completing, either by a cancel request or by the platform.
details.metrics.totalItemsTotal number of files in the job. Returned as a string.
details.metrics.processedItemsFiles successfully ingested so far.
details.metrics.failedItemsFiles that encountered an error.
createTime / finishTimeISO 8601 UTC timestamps. finishTime is null until the job reaches a terminal state.

Poll until state is SUCCEEDED, FAILED, or CANCELLED.

Inspect failures

When state is FAILED, retrieve the list of files that couldn't be processed.

GET /jobs/{id}/items?states=FAILED
curl "https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs/a1b2c3d4-e5f6-7890-abcd-ef1234567890/items?states=FAILED" \
-H "Authorization: Bearer <token>"

The response is a {totalCount, items} envelope. Each entry carries name, path, size, fileTime, state, and a message describing the failure reason. Common causes include transient network errors, missing objects, or insufficient permissions on the source bucket.

states accepts a comma-separated list of PENDING, SUCCEEDED, and FAILED, so the same endpoint also shows which files have been imported so far.

Retry a failed import

After addressing the root cause of the failures, retry the job. The same job ID is reused, and each attempt is recorded as a separate execution, which you can list with GET /jobs/{id}/executions.

POST /jobs:retry
curl -X POST \
"https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs:retry" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"}'

Response: 204 No Content. The job transitions back to PENDING and the worker picks it up shortly.

Cancel a job

Stop a running job before it completes. Only jobs in PENDING or RUNNING state can be canceled. A canceled job can't be retried.

POST /jobs:cancel
curl -X POST \
"https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs:cancel" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"}'

Response: 204 No Content.

List recent jobs

Returns the most recent jobs, ordered by creation date in descending order.

GET /jobs
curl "https://<environment>.apps.dynatrace.com/platform/storage/jobs/v1/jobs?page=1&page-size=20" \
-H "Authorization: Bearer <token>"

Use page and page-size (default 20, maximum 100) to page through the results.

Query imported data

Records are available in Grail as soon as they land—you can query the destination bucket while the job is still running.

fetch logs, bucket: "my-archive-bucket"
| filter loglevel == "ERROR"
| sort timestamp desc
| limit 100

Date filtering

Why date filtering matters

Date filtering is the only mechanism that excludes files before they're read, because the date is encoded in the file path. Filters on record content are applied after a file has been read, so they don't reduce how much is scanned. A tighter date range means fewer files are opened.

endDate is exclusive: the range covers [startDate, endDate).

How date filtering works

When startDate and endDate are provided, the API resolves the date layout from the file paths and then lists only the matching date prefixes, so files outside the range are never read. The resolved layout is returned as timePattern in the preview response.

If no layout is resolved, timePattern returns your prefix followed by /**, the samples carry no fileTime, and the date range is not applied. When that happens, state the layout explicitly in the prefix, which always applies the date range:

/application-logs/<yyyy>/<MM>/<dd>/<HH>/*

Mark the date segments with <yyyy>, <MM>, <dd>, and <HH>, and end the prefix with a glob (* or **). The placeholders must match the real depth of the archive: a day-level pattern against an hour-partitioned archive returns an empty result rather than an error.

Supported path layout

FormatExample paths
Bare numeric (YYYY/MM/DD, optional /HH)2024/01/15/03/app.log.gz 2024/01/15/app.log.gz

Audit completed jobs

When a job reaches a terminal state (SUCCEEDED, FAILED, or CANCELLED), an event is recorded in dt.system.events. Query the full history with:

fetch dt.system.events
| filter event.kind == "JOB_EVENT"
| sort timestamp desc

Related topics

  • Set up external datastores
  • Permissions in Grail
  • Lookup data in Grail
  • How to organize your data stored in Grail
Related tags
Dynatrace Platform