CogniteTimeSeries concept for time series. You create, update, and delete time series as instances with the Instances API, and insert and retrieve their data points with the Time Series API.
This article describes how to create and manage time series in data modeling.
Migrate existing time series
To turn asset-centric time series intoCogniteTimeSeries nodes in the Cognite core data model (cdf_cdm), use the Cognite Toolkit migration plugin. Run cdf migrate timeseries. By default, the command links each existing time series to a data modeling node and locks the original resource so later changes go through data modeling. See Migrating files and time series.
Create time series
In data modeling, each time series is a node in the property graph. You can create, update, and delete time series using the same API as other instances. TheinstanceType is node, and the combination of space and externalId identifies the time series and links it to the data points.
Time series must be of a specific type: numeric, string, or state. You set the type when creating the time series, and you can’t change it later. To decide which type to use, and how to set isStep for numeric time series, see About time series types.
Create time series with the API
To create time series in data modeling, use the create or update nodes/edges endpoint. The node must have data in thecdf_cdm:CogniteTimeSeries/v1 system view to be recognized as a time series.
The type is the only mandatory property.
Example: create time series with minimal properties
Example: create time series with minimal properties
Example: create time series with all properties
Example: create time series with all properties
Create time series with the Python SDK
Example: create time series and insert data points
Example: create time series and insert data points
State time series
State time series represent discrete operational states, for instance,ON/OFF or RUNNING/IDLE/ERROR, from a predefined set of valid states. To create one, first create a state set with the CogniteStateSet view, then create a time series with type: "state" and a stateSet property that links to it.
For complete examples, constraints, and the state-specific aggregates, see State time series.
Synchronization from data modeling to the Time Series API
When you create aCogniteTimeSeries in data modeling, it’s automatically synchronized with the Time Series API (/timeseries).
In the Time Series API, the time series you created in data modeling is identified by its instanceId property:
Synchronization process
A background “sync worker” ensures that time series created in data modeling is synchronized with the same time series seen using the Time Series API.Expected latency
This synchronization process typically happens within seconds, but isn’t instantaneous/atomic. During periods of high load, the process may take a few minutes. If you create a time series in data modeling and immediately query the Time Series API, the newly created time series may not be visible yet.Immediate consistency guarantees
If the Time Series API receives aninstanceId that it doesn’t recognize, it triggers a synchronization for the instance to guarantee that the time series has been synced at least once, though it may not always be fully up to date.
A delay can happen when you update an existing CogniteTimeSeries and, for example, change the unit property. The property may not be immediately updated in the Time Series API.
You can create a time series in data modeling and immediately ingest data points into it. If the background syncer has not yet processed the new time series, the ingestion request triggers a synchronization, ensuring that the time series exists before proceeding.
Deleting CogniteTimeSeries
Time series created in data modeling can only be deleted using the data modeling API. Some time after the time series has been deleted from data modeling (typically within seconds), it is deleted in the Time Series API. If data points are written to the Time Series API after the instance has been deleted by the data modeling service, the data points may appear to be stored (write requests receive a200 OK response) until the time series in the Time Series API has been deleted. After this time, all data will be deleted.
This may cause problems if you delete a time series instance and then recreate it. When a recreated time series uses the same instanceId as a deleted instance,
data points for the newly created instance may get routed to the old time series. As a result, newly written data points may be missing from the new instance since they were deleted as part of the old time series deletion.
When you have to delete and recreate a time series instance, always include a verification step.
Example: Periodically send a POST timeseries/byids request to the Time Series API for the specific instanceId you have deleted, with the ignoreUnknownIds parameter set.
When the Time Series API returns an empty response, it confirms that the instance has been deleted, and you can safely recreate the time series instance.
For more information, see Retrieve time series.
Access control
Data modeling uses spaces for governance and access control. To create and readCogniteTimeSeries, you need the following capabilities:
dataModelsAcl.READto thecdf_cdmspace to read the core data model schema.dataModelInstancesAcl.READ/WRITE/WRITE_PROPERTIESto the space with the time series instances.
dataModelsAcl.READto thecdf_extraction_extensionsspace to read properties set by Cognite extractors.dataModelInstancesAcl.READto thecdf_cdm_unitsspace to retrieve and list units. You can set and read the unit reference on a time series without this capability.
CogniteTimeSeries instance. To read data points, you need dataModelInstancesAcl.READ or WRITE. To insert or delete them, you need WRITE or WRITE_PROPERTIES. The Time Series API also requires dataModelsAcl.READ to the cdf_cdm space. Without it, data point requests fail with 403 Missing capability to read Time series.
Related API reference
Time series and datapoints
Insert, retrieve, and query time series data points using
instanceId.Synthetic time series
Combine time series using arithmetic expressions and functions.
Data point subscriptions
Subscribe to changes in time series data points.
Instances API
Create and manage time series metadata in your data model.