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 (private beta). You set the type when creating the time series. The type affects how the data points are stored, and to prevent potential data loss, you can’t change it later. The isStep property determines how to interpolate between data points, and you can change the property later. Data modeling doesn’t support all the time series properties of the asset-centric data model.
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 (private beta)
This feature is currently in private beta. For more information and to sign up, contact your Cognite representative.
ON/OFF, OPEN/CLOSED, RUNNING/IDLE/ERROR. Unlike numeric or string time series, state time series have a predefined set of valid states and support specialized aggregations for analyzing operational patterns.
Key differences between time series types
| Aspect | Numeric | String | State |
|---|---|---|---|
| Values | Continuous measurements | Free-form text | Predefined state set |
| Aggregations | min/max/avg/sum | Not supported | duration/transitions/count per state |
| Typical use case | Sensor measurements | Labels/comments | Equipment operational states |
Get started
To use state time series:- Create a state set that defines valid states (integer, string pairs) using the
CogniteStateSetview - Create a state time series by setting
type: "state"and linking to the state set via thestateSetproperty. - Ingest state data points with numeric and/or string values.
- Query with specialized aggregations:
stateCount,stateTransitions, andstateDuration.
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 has an instanceId property (reusing the externalId property could cause conflicts with existing time series):
Updates
The properties you can set in data modeling, can only be updated using the Data Modeling API. You can still update the other properties through the Time Series API:externalIdassetIddataSetIdmetadata
externalId property in addition to the instanceId. This can be useful in scenarios where some applications understand externalId, but not instanceId.
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 about the the /byids API endpoint, see the Time Series API documentation.
This information applies to time series created using the data modeling API.
It doesn’t apply to time series created using the Time Series API.
Access control
Data modeling uses spaces for governance and access control, not data sets. To create and read CogniteTimeSeries, you need the following capabilities:dataModelsAcl.READto thecdf_cdmspace to read the core data model schema.dataModelsAcl.READto thecdf_extraction_extensionsspace to read properties set by Cognite extractors.dataModelInstancesAcl.READto thecdf_cdm_unitsspace to use units.dataModelInstancesAcl.READ/WRITE/WRITE_PROPERTIESto the space with the time series instances.
dataSetId or assetId using the Time Series API, the time series and data points may be accessible to users without data modeling access. Users with access to all time series will also have access to time series in data modeling.
Time series with a write-protected data set denies write access to data points, unless the user has datasets:owner access to the data set. Properties set by data modeling aren’t write-protected.
Time Series with an
instanceId cannot have security categories.