Time series

In Cognite Data Fusion, a time series is the resource type for indexing a series of data points in time order. Examples of a time series are the temperature of a water pump asset, the monthly precipitation in a location and the daily average number of manufacturing defects.

Watch this video for a quick introduction to time series:

In this article:

About time series

An asset can have several time series connected to it. A water pump asset can for example have time series that measure the pump temperature, the pressure within the pump, rpm, flow volume, power consumption, and more.

Time series can be analyzed and visualized to draw inferences from the data, for example to identify trends, seasonal movements and random fluctuations. Other common uses of time series analysis include to forecast future values, for example to schedule maintenance, and to control the series by adjusting parameters, for example to optimize the performance of equipment.

A data point is a piece of information associated with a specific time, stored as a numerical or string value. Data points are identified by their timestamps, defined in milliseconds in Unix Epoch time. We do not support fractional milliseconds, and do not count leap seconds.

Use the isString flag on the time series object to decide whether to store data points in a time series as numerical values or as string values.

  • Numerical data points can be aggregated to reduce the amount of data transferred in query responses and improve performance. You can specify one or more aggregates (for example average, minimum and maximum) and also the time granularity for the aggregates (for example 1h for one hour).

    See Aggregating time series data to learn more about how Cognite Data Fusion aggregates and interpolates time series data, and see the details about the available aggregation functions.

  • String data points can store arbitrary information like states (for example open or closed) or more complex information in JSON format. String data points can not be aggregated by Cognite Data Fusion.

Cognite Data Fusion stores discrete data points, but the underlying process measured by the data points can vary continuously. To interpolate between data points, use the isStep flag on the time series object to assume that each value stays the same until the next measurement (isStep), or that it linearly changes between the two measurements (not isStep).

See the time series API documentation for more information about how to work with time series.

Get the datapoints from a time series

You can get datapoints from a time series by using the externalId or the id of the time series.

  1. To get datapoints from a time series by using the externalId, in this case outside_temperature, enter:

      POST /api/v1/projects/publicdata/timeseries/data/list
      Host: api.cognitedata.com
      api-key: <key>
      Content-Type: application/json
      content-length: 99
    
      {
        "items": [
          {
            "limit": 5,
            "externalId": "outside-temperature"
          }
        ]
      }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14

    The response will look similar to this:

      {
        "items": [
          {
            "isString": false,
            "id": 44435358976768,
            "externalId": "outside-temperature",
            "datapoints": [
              {
                "timestamp": 1349732232902,
                "value": 31.62889862060547
              },
              {
                "timestamp": 1349732244888,
                "value": 31.59380340576172
              },
              {
                "timestamp": 1349732245888,
                "value": 31.62889862060547
              },
              {
                "timestamp": 1349732258888,
                "value": 31.59380340576172
              },
              {
                "timestamp": 1349732259888,
                "value": 31.769287109375
              }
            ]
          }
        ]
      }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31

Get aggregate values between two points in time

To visualize or analyze a longer time period, you can extract the aggregate values between two points in time. See Retrieve data points for valid aggregate functions and granularities.

  1. For example, to return the hourly average aggregate with a granularity of 1 hour, for the last 5 hours, for the outside_temperature time series, enter:

      POST /api/v1/projects/publicdata/timeseries/data/list
      Host: api.cognitedata.com
      api-key: <api-key>
      Content-Type: application/json
    
      {
        "items": [
          {
            "limit": 5,
            "externalId": "outside-temperature",
            "aggregates": ["average"],
          "granularity": "1h",
          "start": 1541424400000,
          "end":"now"
            
          }
    
        ]
      }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19

    The response will look similar to this:

      {
        "items": [
          {
            "id": 44435358976768,
            "externalId": "outside-temperature",
            "datapoints": [
              {
                "timestamp": 1541422800000,
                "average": 26.3535328292538
              },
              {
                "timestamp": 1541426400000,
                "average": 26.34716274449083
              },
              {
                "timestamp": 1541430000000,
                "average": 26.35558703492914
              },
              {
                "timestamp": 1541433600000,
                "average": 26.36287845690146
              },
              {
                "timestamp": 1541437200000,
                "average": 26.36948613080317
              }
            ]
          }
        ]
      }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
Last Updated: 8/19/2019, 8:29:01 AM