Increment

Overview

  • This set of api endpoints allows data at a timestamp to be atomically incremented. This is useful for storing counts or event-like data. A timestamp and increment amount is specified and the series is atomically incremented.

    All data is written using the REST interface. Datapoints are represented by a dictionary containing a t for the timestamp and a v for the value. TempoDB supports two types for the value: integers and floats.

    There are two main methods for incrementing data. Several datapoints can be written for a single series in one call. Or, several datapoints for different series at the same timestamp can be written. Single series writes are achieved by referencing the series by id or key.

  • Upserts

    Incrementing a datapoint in a series referenced by key will cause that series to be created if the key doesn't exist. This is sort of like the upsert feature of other databases. An increment on a datapoint that doesn't exist will set the value at that timestamp to the increment amount.

  • Operations

    The following increment-related operations are supported:

    • Increment Data by ID
    • Increment Data by Key
    • Bulk Increment Multiple Series

Increment Data by ID

  • Description

    Increments the value at a specific timestamp of a series referenced by ID.

  • Resource URL

    POST /series/id/{id}/increment/
  • URL Parameters

    • id

      Specifies the id of the series to increment.

      Example Values: 01868c1a2aaf416ea6cd8edd65e7a4b8

  • Querystring parameters

    None

  • Request Body

    An array of dictionaries representing a datapoint. You can add as many timestamp/value pairs for the series at a time as you’d like. The value is the amount to increment. If this timestamp has never been written, the value is set. Increments only apply to longs. All doubles will be converted to a long before incrementing.

  • Response

    A 200 OK if the request completes.

  • Side Effects

    The values at each timestamp are incremented by the specified value.

  • Example Request

    post/series/id/01868c1a2aaf416ea6cd8edd65e7a4b8/increment/post data
    1. [
    2. {"t":"2012-01-08T00:21:54.000+0000","v":4},
    3. {"t":"2012-01-08T00:21:55.000+0000","v":3},
    4. {"t":"2012-01-08T00:21:56.000+0000","v":3}
    5. ]

    The values are incremented by the specified values. For instance, if the value at 2012-01-08T00:21:54.000+0000 before the call was 12, the value is incremented by 4 to 16.

Increment Data by Key

  • Description

    Increments the value at a specific timestamp of a series referenced by key. A new series is created with the provided key if it doesn't already exist.

  • Resource URL

    POST /series/key/{key}/increment/
  • URL Parameters

    • key

      Specifies the key of the series to increment.

      Example Values: my-custom-key

  • Querystring parameters

    None

  • Request Body

    An array of dictionaries representing a datapoint. You can add as many timestamp/value pairs for the series at a time as you’d like. The value is the amount to increment. If this timestamp has never been written, the value is set. Increments only apply to longs. All doubles will be converted to a long before incrementing.

  • Response

    A 200 OK if the request completes.

  • Side Effects

    The values at each timestamp are incremented by the specified value.

    A new series is created if the key did not previously exist.

  • Example Request

    post/series/key/my-custom-key/increment/post data
    1. [
    2. {"t":"2012-01-08T00:21:54.000+0000","v":4.164},
    3. {"t":"2012-01-08T00:21:55.000+0000","v":3.121},
    4. {"t":"2012-01-08T00:21:56.000+0000","v":3.629}
    5. ]

    The values are incremented by the specified values. For instance, if the value at 2012-01-08T00:21:54.000+0000 before the call was 12, the value is incremented by 4 to 16.

Bulk Increment Multiple Series

  • Description

    Increments data for multiple series at the same timestamp.

    Series can be referenced by either id or key. A timestamp and an array of id/key and value pairs are sent in the request body. This is useful for incrementing multiple measurements at a single time.

  • Resource URL

    POST/increment/
  • URL Parameters

    None

  • Querystring parameters

    None

  • Request Body

    A JSON object with a timestamp ("t") and an array of objects containing series identifiers (id/key) and values.

  • Response

    A 200 OK if the request completes.

  • Side Effects

    The values for each series are incremented by the specified values.

    A new series is created if a key did not previously exist.

  • Example Request

    post/increment/post data
    1. {
    2. "t":"2012-01-08T00:21:54.000+0000",
    3. "data":[
    4. {"id":"01868c1a2aaf416ea6cd8edd65e7a4b8","v":4},
    5. {"id":"38268c3b231f1266a392931e15e99231","v":7},
    6. {"key":"your-custom-key","v":1},
    7. {"key":"foo","v":2},
    8. ]
    9. }