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

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

An array of Metric items.

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

An array of Points items.

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

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.
metricstringIf not provided, returns a list of available metrics.

Response

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.

GetDeviceSchema

Endpoint

HTTP
POST /metric/getDeviceSchema

Authorized User Role

user

Request Body

FieldType
cloudIdstring

Response

A object.

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

An array of Items items.

FieldTypeNotes
accumulatebooleanAccumulate result into a single result.
cloudIdstringDevice Cloud ID.
dimensionsobjectDimensions for metric.
fieldstringDatabase field name.
metricstringMetric name.
modelstringDatabase model name.
namespacestringMust be set to Embedthis/Device.
periodnumberMetric timespan period.
statisticstringMetric statistic. Select from: avg, min, max, count, sum.

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

An array of Metric Array items.

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

An array of Points items.

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

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.