MetricBase Time Series API
-
- UpdatedJan 30, 2025
- 42 minutes to read
- Yokohama
- API reference
The MetricBase Time Series API provides endpoints to insert data into, retrieve information from, and to run transforms against a MetricBase database.
This API can only be used when the MetricBase plugin (com.snc.clotho) is installed and activated.
Role required to write to this API: clotho_rest_put.
The examples in this section were created using data in the MetricBase (com.snc.clotho) plugin.
MetricBase Time Series - GET /now/clotho/table/{table}/{subject}/{metric}
Retrieves specified time series data from the MetricBase database.
URL format
Versioned URL: /api/now/{api_version}/clotho/table/{table}/{subject}/{metric}
Supported request parameters
Name | Description |
---|---|
sysparm_display_value | Flag that indicates whether to label the result data with the subject record display value if no other label is specified. Valid values:
Data type: Boolean Default: false |
sysparm_end | Required. End time of the evaluation period. An empty or missing value is treated as the current time. Time values are inclusive of this end time. Data type: String Format: ISO 8601
(UTC), either:
|
sysparm_start | Required. Start time of the evaluation period. The special value all can be used to set the start time as the current time minus the maximum retention period for the
specified metrics. An empty or missing value is treated as an implicit all . Time values are inclusive of this start time.Data type: String Format: ISO 8601 (UTC), either:
|
Name | Description |
---|---|
None |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Header | Description |
---|---|
Accept | Data format of the response body. Only supports application/json. |
Header | Description |
---|---|
None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Status code | Description |
---|---|
200 | Successful. The request was successfully processed. |
401 | Unauthorized. The user credentials are incorrect or have not been passed. |
500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON or XML)
Example: cURL request
MetricBase Time Series - GET /now/clotho/transform/{table}/{metric}
Transforms the specified data based on the specified parameters.
URL format
Versioned URL: /api/now/{api_version}/clotho/transform/{table}/{metric}
Supported request parameters
Name | Description |
---|---|
api_version | |
metric | Name of the column in the table identified in the
subject parameter to use as the metric. Data type: String |
table | Name of the table containing the GlideRecord associated with this series. Data type: String |
Name | Description |
---|---|
None |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Header | Description |
---|---|
Accept | Data format of the response
body. Supported types: application/json or
application/xml.
Default: application/json |
Header | Description |
---|---|
None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Status code | Description |
---|---|
200 | Successful. The request was successfully processed. |
401 | Unauthorized. The user credentials are incorrect or have not been passed. |
500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON or XML)
Example: cURL request
Output:
MetricBase Time Series - POST /now/clotho/accumulate
Accumulates metric values at specified timestamp and saves the result to the database rather than overwriting the value.
Use this API to handle metrics that can be summed for an accumulation, such as kilowatt-hours (kWhs) of electricity. Accumulate makes a call for each metric at the provided timestamp. For example, collected kilowatts for a heater, electric kettle, and washing machine would result in three calls to accumulate.
URL format
Versioned URL: /api/now/{api_version}/clotho/accumulate
Supported request parameters
Name | Description |
---|---|
api_version | Optional. Version of the endpoint to access. For example, v1 or v2. Only specify this value to use an endpoint version other than the
latest.
Data type: String |
Name | Description |
---|---|
default_value | Default value for accumulation at a given timestamp. Used only during the first call to accumulate if a value is unavailable for a given timestamp.
A use case could be accumulating a watts metric for a total_power. You want to accumulate watts for a router connected to an outlet without a power meter to measure it. If you know the consumption value and it is constant), you can use the constant value as a default value to accumulate total_power. For example, you would use 20 if the router is constantly plugged in and consumes 20 Watts. Data type: String Default: 0 |
sysparm_ignore_unknown_series | Flag that indicates whether to ignore an unknown series and continue the transaction without returning an error. Valid values:
Default: true |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Header | Description |
---|---|
Accept | Data format of the response body. Only supports application/json. |
Content-Type | Data format of the request body. Only supports application/json. |
Header | Description |
---|---|
None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Status code | Description |
---|---|
200 | Successful. The request was successfully processed. |
401 | Unauthorized. The user credentials are incorrect or have not been passed. |
500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON or XML)
Name | Description |
---|---|
message | Message indicating success (OK) or error. |
Example: cURL request
This example shows how to accumulate metric values at a given timestamp.
Output provided with successful results.
MetricBase Time Series - POST /now/clotho/transform
Retrieves and optionally groups time series data for one or more metrics after applying a specified list of transforms that form a linear pipeline.
URL format
Versioned URL: /api/now/{api_version}/clotho/transform
Supported request parameters
Name | Description |
---|---|
api_version | Optional. Version of the endpoint to access. For example, v1 or v2. Only specify this value to use an endpoint version other than the
latest.
Data type: String |
Name | Description |
---|---|
sysparm_display_value | Flag that indicates whether to label the result data with the subject record display value if no other label is specified. Valid values:
Data type: Boolean Default: false |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Header | Description |
---|---|
Accept | Data format of the response body. Only supports application/json. |
Content-Type | Data format of the request body. Only supports application/json. |
Header | Description |
---|---|
None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Response body parameters (JSON or XML)
Supported transforms
Example: cURL request
Output:
MetricBase Time Series - POST /now/clotho/transform/stream
Returns a stream of transformed time series data for one or more metrics after applying the specified list of transforms.
Streaming data in this manner allows you to process the data as individual transforms are completed and returned, rather than waiting for all transform results to be completed and downloaded. If large amounts of data need to be processed by the client, this type of processing reduces the end-to-end processing time and potentially reduces the memory usage on the client.
- Specify the streamed data to be encoded in a binary format,
- Serialize streamed data into a JSON array, or
- Stream data back to the client in a wide or narrow CSV format.
URL format
Versioned URL: /api/now/{api_version}/clotho/transform/stream
Supported request parameters
Name | Description |
---|---|
api_version | Optional. Version of the endpoint to access. For example, v1 or v2. Only specify this value to use an endpoint version other than the
latest.
Data type: String |
Name | Description |
---|---|
sysparm_display_value | Flag that indicates whether to label the result data with the subject record display value if no other label is specified. Valid values:
Data type: Boolean Default: false |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Header | Description |
---|---|
Accept | Data format of the response body.
Supports the following:
text/csv;format=narrow or
text/csv;format=wide . |
Content-Type | Data format of the request body. Only supports application/json. |
Header | Description |
---|---|
None | Data format of the response body. Based on the specified Accept values of the request, use:
If multiple Accept types are specified, the first supported type is returned. |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Response body parameters (Octet-stream or JSON)
Supported transforms
Example: cURL request
The following example shows how to call this endpoint to return a JSON stream for metrics
on the mb_demo_drone table. Note: While the objects in this example are expanded to multiple
lines for legibility, in an actual result each returned object is on its own line. You can
make the same call and return an octet stream by setting --header
"Accept:application/octet-stream" \
.
Response:
Example
The following cURL example uses the CSV format option to stream back the altitude values (stored in the database as "mb_demo_mt_altitude") of the last day for each drone stored in the mb_demo_drone [Drones] table of the Metricbase Demo plugin. In the example, the data is returned in a narrow table format with three columns: the Sys_id of the subject identifying the drone, the time stamp of value, and the altitude value.
Output:
MetricBase Time Series - POST /now/clotho/put
Adds time series data to the MetricBase database.
URL format
Versioned URL: /api/now/{api_version}/clotho/put
Supported request parameters
Name | Description |
---|---|
api_version | Version of the endpoint to access. For example,
v1 or v2. Only specify this value
to use an endpoint version other than the latest.
Data type: String |
Name | Description |
---|---|
sysparm_ignore_unknown_series | Flag that indicates whether to ignore unknown series and continue the
transaction without returning an error. Valid values:
Default: true |
Headers
The following request and response headers apply to this HTTP action only, or apply to this action in a distinct way. For a list of general headers used in the REST API, see Supported REST API headers.
Header | Description |
---|---|
Accept | Data format of the response body. Only supports application/json. |
Content-Type | Data format of the request body. Only supports application/json. |
Header | Description |
---|---|
None |
Status codes
The following status codes apply to this HTTP action. For a list of possible status codes used in the REST API, see REST API HTTP response codes.
Status code | Description |
---|---|
200 | Successful. The request was successfully processed. |
401 | Unauthorized. The user credentials are incorrect or have not been passed. |
500 | Internal server error. An unexpected error occurred while processing the request. The response contains additional information about the error. |
Response body parameters (JSON or XML)
Name | Description |
---|---|
message | Message that indicates the status of the request, such as ok if the request processed successfully. |
Example: cURL request
On this page
- MetricBase Time Series - GET /now/clotho/table/{table}/{subject}/{metric}
- MetricBase Time Series - GET /now/clotho/transform/{table}/{metric}
- MetricBase Time Series - POST /now/clotho/accumulate
- MetricBase Time Series - POST /now/clotho/transform
- MetricBase Time Series - POST /now/clotho/transform/stream
- MetricBase Time Series - POST /now/clotho/put