Post metrics data

POST/projects/{projectId}/entities/{entityId}/metrics/{metricsDefinitionId}/data

Base URL: https://api.tinkermode.com

Post metrics data. The client can use this method to inject time-series data of the metrics.

This method injects the data into the corresponding collection in the Time Series Database instance. Also, it sends an Entity metrics update system event (_entityMetricsUpdate_) to the home of the Entity.

For a TSDBv2 metrics definition, do not post a different value for a metric at a timestamp that already has a value. TSDBv2 keeps only one of the two values, and which one is not defined. Reads can return either value, and the result can change from one read to the next. Posting the same value again is safe. In TSDBv1, a later post replaces the value at that timestamp.

For a TSDBv2 metrics definition, posting data for an hour that has ended and already has data makes TSDBv2 compute that hour's aggregated values again. Queries for aggregated values of that hour can keep returning the earlier values.

Authentication

Send an Authorization header of the form ModeCloud <AUTH_CODE>.

Must contain a user API key of a user with permission to create the entity metrics, a service account token with the same permission, or a project API key with admin permission.

Path parameters

NameTypeRequiredConstraintsDescription
projectIdintegerYesThe unique ID for a specified project.
entityIdstringYesEntity ID (unique within project)
metricsDefinitionIdstringYesMetrics definition ID (unique within entity class)

Request body

Content type: application/json

PropertyTypeRequiredConstraintsDescription
recordsarray<object>Yesread-only (server-generated)Time-series data. Each entry contains the timestamp of the value in RFC3339 format.
Properties of records
PropertyTypeRequiredConstraintsDescription
tagsarray<string>Noread-only (server-generated)An array of tags. The items must correspond to the items in tagNames
timestampstringYesread-only (server-generated)Time in RFC3339 format
valuesarray<number>Yesread-only (server-generated)An array of values. The items must correspond to the items in valueNames
tagNamesarray<string>Noread-only (server-generated)List of unique Identifiers of string tags in metrics.
valueNamesarray<string>Yesread-only (server-generated)List of unique Identifiers of numerical fields in metrics.

Request example

{
  "records": [
    {
      "tags": [
        "5DEF12AA3B",
        "100"
      ],
      "timestamp": "2021-04-10T01:12:22Z",
      "values": [
        89.8,
        77,
        9
      ]
    },
    {
      "tags": [
        "5DEF12AA3B",
        "102"
      ],
      "timestamp": "2021-04-10T01:12:32Z",
      "values": [
        87.2,
        77,
        8.33
      ]
    },
    {
      "tags": [
        "5DEF12AA3B",
        "102"
      ],
      "timestamp": "2021-04-10T01:12:43Z",
      "values": [
        87.5,
        75,
        7.92
      ]
    },
    {
      "tags": [
        "5DEF12AA3B",
        "100"
      ],
      "timestamp": "2021-04-10T01:12:52Z",
      "values": [
        90.3,
        75,
        6.01
      ]
    }
  ],
  "tagNames": [
    "pid",
    "diag"
  ],
  "valueNames": [
    "loi",
    "tem",
    "bri"
  ]
}

Responses

204 The data has been successfully processed. There is no response body.

413 For a TSDBv2 metrics definition, the converted CSV data exceeds Loom's 1 MiB import limit. The server writes no records for this size rejection. Send the records in smaller requests. The reason field of the response body is OBJECT_TOO_LARGE.

Content type: application/json

PropertyTypeRequiredConstraintsDescription
dataobjectNoread-only (server-generated)Any relevant data related to error.
reasonstringYesread-only (server-generated)Reason of error.