Returns a list of all metrics belonging to a thing template as per the specified criteria. This API is paginated and returns 20 metrics by default. An metric is uniquely identified by an 'metric_key'. This key should be used in all the other API referencing a particular metric.

Params

Param name Description
thing_template_key
optional

Key of thing template for which metrics to be fetched. This field is required


Value: Must be a String
page
optional

Page number of results to be fetched, Default 1


Value: Must be Integer.
per
optional

Number of metrics to be returned in one page, Default 20


Value: Must be Integer.
order_by
optional

Field on which metrics should be sorted


Value: Must be a String
order
optional

Order, “asc” or “desc”, in which results should be sorted


Value: Must be a String
search
optional

Keywords based on which metrics should be searched. Currently you can search metrics on - metric_key, name, tags or user_defined_properties


Value: Must be a String
scope
optional

Matching condition if multiple keywords are specified for search. Valid values are “all” or “any”. Default is “all”


Value: Must be a String
timestamp_format
optional

Format, “str” or “int”, in which timestamps should be returned, Default “int”


Value: Must be a String
pretty
optional

Return a pretty formatted response if true, Default is false


Value: Must be a Boolean
field_list
optional

List of fields required in the result.


Value: Must be an array of any type
is_oem
optional

Returns metrics of child accounts if is_oem flag is true.


Value: Must be one of: <code>true</code>, <code>false</code>, <code>true</code>, <code>false</code>.

Examples

Request - listing all metrics belonging to a thing template without any criteria
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"thing_template_key":"af31ae5fb2"}' https://api.datonis.io/api/v3/metrics

Response (returns first 20 records)
{
  "total_count": 4,
  "page": 1,
  "metrics": [
    {
      "abbreviation": "capacity",
      "created_at": 1448364456,
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "4f9b9764t7",
      "name": "capacity",
      "unit_of_measure": "kilogram",
      "updated_at": 1448364456,
      "treatments": [

      ],
      "thing_template_key": "af31ae5fb2"
    },
    {
      "abbreviation": "speed",
      "created_at": 1448364456,
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "4tb363cc88",
      "name": "maximum_rotational_speed",
      "unit_of_measure": "RPM",
      "updated_at": 1448364456,
      "treatments": [

      ],...
Request - listing metrics belonging to a thing template by specifying number of metrics to be returned at a time (page size) and specific set to be returned (page)
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"thing_template_key":"af31ae5fb2","per":"2","page":"2"}' https://api.datonis.io/api/v3/metrics

Response (returns page 2 with 2 metrics per page)
{
  "total_count": 4,
  "page": "2",
  "metrics": [
    {
      "abbreviation": "noise",
      "created_at": 1448364456,
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "278t29123d",
      "name": "noise_level",
      "unit_of_measure": "dB",
      "updated_at": 1448364456,
      "treatments": [

      ],
      "thing_template_key": "af31ae5fb2"
    },
    {
      "abbreviation": "voltage",
      "created_at": 1448364457,
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "492c52bf56",
      "name": "voltage",
      "unit_of_measure": "volt",
      "updated_at": 1448364457,
      "treatments": [

      ],
     ...
Request - listing metrics belonging to a thing template ordered by a field with string formatted timestamps
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"thing_template_key":"af31ae5fb2","timestamp_format":"str","order_by":"name","order":"desc"}' https://api.datonis.io/api/v3/metrics

Response (returns metrics in the reverse order of their name and timestamps in string format)
{
  "total_count": 4,
  "page": 1,
  "metrics": [
    {
      "abbreviation": "voltage",
      "created_at": "2015/11/24 11:27:37",
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "492c52bf56",
      "name": "voltage",
      "unit_of_measure": "volt",
      "updated_at": "2015/11/24 11:27:37",
      "treatments": [

      ],
      "thing_template_key": "af31ae5fb2"
    },
    {
      "abbreviation": "noise",
      "created_at": "2015/11/24 11:27:36",
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "278t29123d",
      "name": "noise_level",
      "unit_of_measure": "dB",
      "updated_at": "2015/11/24 11:27:36",
     ...
Request - listing metrics belonging to a thing template based on some search criteria with all keywords matching
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"thing_template_key":"af31ae5fb2","search":"capacity level"}' https://api.datonis.io/api/v3/metrics

Response (returns metrics containing both keywords 'capacity' as well as 'level')
{
  "total_count": 0,
  "page": 1,
  "metrics": [

  ]
}
Request - listing metrics belonging to a thing template based on some search criteria with any of the keywords matching
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"thing_template_key":"af31ae5fb2","search":"capacity level","scope":"any"}' https://api.datonis.io/api/v3/metrics

Response (returns metrics containing either of the keywords 'capacity' or 'level')
{
  "total_count": 2,
  "page": 1,
  "metrics": [
    {
      "abbreviation": "capacity",
      "created_at": 1448364456,
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "4f9b9764t7",
      "name": "capacity",
      "unit_of_measure": "kilogram",
      "updated_at": 1448364456,
      "treatments": [

      ],
      "thing_template_key": "af31ae5fb2"
    },
    {
      "abbreviation": "noise",
      "created_at": 1448364456,
      "data_type": 0,
      "description": "Metric for thing template Washing Machine",
      "metric_key": "278t29123d",
      "name": "noise_level",
      "unit_of_measure": "dB",
      "updated_at": 1448364456,
      "treatments": [

      ],
      "thing_template_key": "af31ae5fb2"
    }
  ]
}