Skip to content

Metric

API to manage metrics including the ability to get and set metrics, and to get a list of available metrics.

The Ioto service creates metrics for device and service data. It stores the current live and historical metric values. Metrics are calculated for for the last "5 minutes", hour, day, week, month, and year. Statistics are kept for the average, min, max, count and the sum of metric values.

Metrics are named and grouped into Namespaces with metric Dimensions selecting instances of a metric for a specific resoure.

See Also

Fetch

Fetch metric values.

This API fetches multiple metric values in a single request.

Endpoint

HTTP
POST /metric/fetch

Authorized User Role

user

Request Body

FieldTypeRequiredNotes
itemsarrayyesArray of metric requests.
deviceIdstringyesDevice ID owning the metrics.

Metric Request

FieldTypeRequiredDefaultNotes
accumulatebooleanAccumulate result into a single result.
cloudIdstringDevice Cloud ID.
dimensionsobjectDimensions for metric.
fieldstringDatabase field name.
limitnumberNumber of items to fetch.
metricstringMetric name.
modelstringDatabase model name.
namespacestringyesMust be set to Embedthis/Device.
periodnumber300Metric timespan period.
startnumberMetric range start.
statisticstringyesavgMetric statistic. Select from: avg, min, max, count, sum.

Response

Paged response.

FieldTypeNotes
dataarrayAn array of devices owned by the user.
nextstringPaged cursor to use for the next page of items.
prevstringPages cursor to use for the previous page of items.

Metric

FieldTypeNotes
dimensionsobjectDimensions for the metric.
metricstringMetric name.
namespacestringAlways set to Embedthis/Device.
ownerstringThe service owning the metric.
periodnumberMetric timespan period.
pointsarrayArray of data points (see below).
samplesnumberNumber of data points in the period.
*any

Dimensions

Dimensions for the metric.

FieldType
*any

Point

FieldTypeNotes
valuenumberMetric value.
timestampnumberLast update to the metric value in seconds since Jan 1, 1970.
countnumberNumber of data values contributing to the metric value.

Get

Get an accumulated metric.

This API is used by devices to retrieve a metric statistic over the MQTT protocol.

To get metrics over REST HTTP, use the fetch API.

Protocol

MQTT

Endpoint

mqtt: /metric/get

Authorized User Role

device

Request Body

FieldTypeDefaultNotes
dimensionsobjectDimensions for metric.
metricstringMetric name.
periodnumber300Metric timespan period.
statisticstringavgMetric statistic.

Response

Paged response.

FieldTypeNotes
dataarrayAn array of merics.
nextstringPaged cursor to use for the next page of items.
prevstringPages cursor to use for the previous page of items.

Metric

FieldTypeNotes
dimensionsobjectDimensions for the metric.
metricstringMetric name.
namespacestringAlways set to Embedthis/Device.
ownerstringThe service owning the metric.
periodnumberMetric timespan period.
pointsarrayArray of data points.
samplesnumberNumber of data points in the period.

Dimensions

Dimensions for the metric.

FieldType
*any

Point

FieldTypeNotes
valuenumberMetric value.
timestampnumberLast update to the metric value in seconds since Jan 1, 1970.
countnumberNumber of data values contributing to the metric value.

GetDeviceSchema

Get a device schema.

Endpoint

HTTP
POST /metric/getDeviceSchema

Authorized User Role

user

Request Body

FieldTypeNotes
cloudIdstringCloud ID.

Response

Schema definition.

GetMetricList

Get a list of available metrics.

Endpoint

HTTP
POST /metric/getMetricList

Authorized User Role

user

Request Body

FieldTypeRequiredRoleNotes
cloudIdstringyesownerOverride, device cloud containing the metrics.
namespacestringMetric namespace. If not provided, the API returns a list of namespaces.
metricstringMetric name. If not provided, returns a list of available metrics.
modelstringDatabase model.

Response

Object Record.

FieldTypeNotes
namespacesarrayReturns the requested namespace. If not provided, returns a list of available namespaces.
metricsarrayIf a namespace is provided, returns a list of available metrics.
dimensionsarrayIf a namespace and metric are provided, returns a list of available metric dimensions.

Set

Set a metric value.

This API is used by devices to emit a metric value. It is sent over MQTT rather than via REST.

Protocol

MQTT

Endpoint

mqtt: /metric/set

Authorized User Role

device

Request Body

FieldTypeNotes
metricstringMetric name.
valuenumberMetric value.
dimensionsarrayArray of dimensions for metric.
bufferobjectMetric buffering options.