Skip to main content
The migration plugin is an experimental feature. Updates to the Cognite Toolkit are likely to introduce changes to the described commands and processes.
This guide walks data engineers through migrating system-generated events from an asset-centric Cognite Data Fusion (CDF) project to records in a target stream using the Streams API.

Prerequisites

Before migrating events to records, complete the following:
  1. Enable the migrate and records-migrate alpha flags in your cdf.toml file:
cdf.toml
  1. Provision a target stream with sufficient record and storage capacity. See Choose and size streams for planning guidance. cdf migrate events-to-records validates stream capacity before it runs and raises an error if the stream does not exist or has insufficient capacity.
  2. Deploy one or more containers with usedFor: record in the target space.

Required capabilities

The following capabilities are required to run cdf migrate events-to-records:

Migrating events to records

Migrate human-created events (work orders, inspections, maintenance records) to data modeling nodes instead of records. See Migrating events.
Create a YAML config file, select events by data set or CSV file, then run cdf migrate events-to-records.
1

Create the YAML config file

Define the target stream and property mappings. See Config file.
2

Choose how to select events

Use data set selection with a defaultMapping, or CSV file selection to map specific events, such as status events in the Kelmarsh example.
3

Run `cdf migrate events-to-records`

Pass --config-file and either --data-set-id or --mapping-file, or run without selection flags for interactive mode. See cdf migrate events-to-records --help.
4

Verify the migration

Query the target stream and confirm that records exist for the selected events. See Verify the migration.

Config file

Unlike other migration commands, cdf migrate events-to-records requires a --config-file YAML that defines the target stream and property mappings. The config file names one or more mappings by externalId and maps source event fields to record container properties. Use defaultMapping when every event in a data set shares the same mapping, or when CSV rows omit ingestionMapping. Replace the placeholder values in the example below with your target stream, container, and field mappings.
events_to_records.config.yaml
  • streamExternalId: External ID of the target stream. The stream must already exist.
  • resourceType: Must be event.
  • defaultMapping: Mapping externalId to use when --data-set-id is set, or when a CSV row omits ingestionMapping.
  • mappings: Named mappings. propertyMapping maps source event field names to container property names.

Data set selection

To migrate all events in a data set, run:
Replace <path to config yaml> with a path relative to your Cognite Toolkit project root. Replace <data set id> with the integer internal ID of the asset-centric source data set. The config file must include defaultMapping, because all events in the data set use the same mapping. To select the data set interactively, run:
The command prompts you to select the source data set. See cdf migrate events-to-records --help for details.

CSV file selection

To migrate events using a CSV mapping file, run:
Replace <path to config yaml> and <path to csv file> with paths relative to your Cognite Toolkit project root. This CSV file migrates a Kelmarsh wind farm status event:
migration.events_to_records.csv
Required columns:
  • space: The space of the resulting record.
  • externalId: The external ID of the resulting record.
  • id: The integer internal ID of the source event to migrate.
Optional columns:
  • ingestionMapping: Mapping externalId from the config file for this row. If omitted, the config file defaultMapping is used. Unlike cdf migrate events, there are no consumerViewSpace, consumerViewExternalId, or consumerViewVersion columns.

Verify the migration

Query the target stream and confirm that records exist for the migrated events. In CDF, open the stream in Data management, or query record count through the Streams API. Use --skip-existing to query the target stream before uploading and skip records that already exist. This helps resume a partially completed migration without creating duplicate records. See cdf migrate events-to-records --help for the full list of options, including --dry-run, --log-dir, --yes, and --verbose.

What cdf migrate events-to-records does

When you run cdf migrate events-to-records, the migration plugin performs the following steps on batches of events:
1

Download events

The Cognite Toolkit reads events from the asset-centric /events/byids or /events/list endpoints, depending on the selection method.
2

Map event fields to record properties

The Cognite Toolkit applies the mapping from the config file mappings section. propertyMapping maps source event field names to target container property names. Each event uses the mapping from the CSV ingestionMapping column, the --data-set-id defaultMapping, or the config file defaultMapping.
3

Write records to the target stream

The Cognite Toolkit writes migrated records to the target stream through the Streams API.
4

Skip existing records (optional)

When --skip-existing is set, the Cognite Toolkit queries the target stream first and skips records that already exist.

Further reading

Last modified on August 21, 2026