Skip to main content

Metrics service

The metrics service provides resources for retrieving collected time series metric data, aggregated into the intervals you specify. To work with the definitions that describe what a metric measures, use the metric resources of the dictionary service.

Resource list

POST /v1/metrics:search

Return time series metric data for a single entity, aggregated into fixed-length periods.

Note

This endpoint returns data for the first entity that matches entityClause only. Pagination doesn't advance to a second entity. Write entityClause so that it identifies one entity. If it matches more than one, the results are incomplete and no error is returned.

The field value in a filter must match a field key defined on the tenant's entities. To list the available keys, use the list default fields and field sources resource of the model management service. The fieldSources map in that response classifies each key as a property, a core property, or a dimension. Prefix core property keys with coreProperties. and dimension keys with dimensions. when you reference them in a filter. Property keys, such as source, device, and name, take no prefix.

Request template

An abstract preview of a JSON request that returns hourly averages for one entity.

{
  "entityClause": {
    "and": {
      "clauses": [
        {
          "filter": {
            "field": "<entity-field>",
            "operation": "<operation>",
            "value": "<value>"
          }
        }
      ]
    }
  },
  "metricClause": {
    "filter": {
      "field": "<metric-field>",
      "operation": "<operation>",
      "value": "<value>"
    }
  },
  "timeRange": {
    "start": "<timestamp>",
    "end": "<timestamp>"
  },
  "downsample": {
    "aggregator": "<aggregator>",
    "period": "<duration>"
  },
  "pageSize": <integer>,
  "pageToken": "<token>"
}

Request fields

Field

Type

Required

Description

entityClause

object

Yes

The criteria that identify the entity to return metric data for. The object contains exactly one clause. For the clause types and the fields each one takes, see Clause types.

metricClause

object

No

The criteria that select which of the entity's metrics to return. The object contains exactly one clause and takes the same form as entityClause, but supports a smaller set of operations. For the clause types and the fields each one takes, see Clause types.

timeRange

object

Yes

The period of time to return metric data for.

timeRange.start

string

Yes

The beginning of the period, as a timestamp. For example, 2026-09-11T17:29:00.000Z.

timeRange.end

string

Yes

The end of the period, as a timestamp. For example, 2026-09-11T18:29:00.000Z.

downsample

object

Yes

The aggregation to apply to the data points before they're returned.

downsample.aggregator

string

Yes

The function that combines the data points in each period. Accepted values:

  • COUNT: The number of data points in the period.

  • DELTA: The change in value across the period.

  • INTERPOLATE: An estimated value for each period, derived from the surrounding data points.

  • LAST: The most recent value in the period.

  • MAX: The highest value in the period.

  • MEAN: The average of the values in the period.

  • MIN: The lowest value in the period.

  • NEXT_OLDER: The most recent value collected before the period.

  • NONE: No aggregation.

  • P5: The 5th percentile of the values in the period.

  • P50: The 50th percentile of the values in the period.

  • P95: The 95th percentile of the values in the period.

  • P99: The 99th percentile of the values in the period.

  • RATE: The rate of change across the period.

  • STDDEV: The standard deviation of the values in the period.

  • SUM: The total of the values in the period.

You can send the equivalent numeric value instead of the name, but the name is clearer and is used throughout this documentation.

downsample.period

string

Yes

The length of each aggregation period, as a duration. For example, 3600s returns one aggregated data point per hour.

pageSize

integer

No

The maximum number of metrics to return in one page of results.

pageToken

string

No

The token that identifies the page of results to return. Use the nextPageToken value from the previous response.

Clause types

The entityClause and metricClause fields each take an object that contains exactly one of the following clauses. The and, or, and not clauses contain other clauses and can be nested to any depth. The remaining clauses are single comparisons.

Clause

Description

and

Matches only when every clause in the clauses array matches.

filter

Compares one field to one value. Takes a field key, an operation, and a value, which can be a string, a number, or a boolean. Accepted operations:

  • OP_CONTAINS: The field value contains the specified value.

  • OP_END_WITH: The field value ends with the specified value.

  • OP_EQUALS: The field value matches the specified value exactly.

  • OP_EXISTS: The field is present.

  • OP_GREATER: The field value is greater than the specified value.

  • OP_GREATER_OR_EQ: The field value is greater than or equal to the specified value.

  • OP_LESS: The field value is less than the specified value.

  • OP_LESS_OR_EQ: The field value is less than or equal to the specified value.

  • OP_NOT_CONTAINS: The field value doesn't contain the specified value.

  • OP_NOT_EQUALS: The field value doesn't match the specified value.

  • OP_REGEX: The field value matches the regular expression in the specified value.

  • OP_STARTS_WITH: The field value begins with the specified value.

  • OP_TEXT: The field value matches the specified value as text.

In a metricClause, only OP_EQUALS, OP_EXISTS, OP_GREATER, OP_GREATER_OR_EQ, OP_LESS, OP_LESS_OR_EQ, and OP_NOT_EQUALS are supported. The other operations return an error.

You can send the equivalent numeric value instead of the operation name, but the name is clearer and is used throughout this documentation.

in

Matches when the field key matches any entry in the values array. Combine it with not to exclude a set of values.

not

Matches only when the clause in the clause field doesn't match.

or

Matches when any clause in the clauses array matches.

range

Matches when the field in the path key falls between the bounds set by gte, gt, lte, and lt. Supported in a metricClause.

withIds

Matches the entities whose identifiers appear in the ids array. Supported in a metricClause.

The following examples show each clause type.

{ "and": { "clauses": [
  { "filter": { "field": "source", "operation": "OP_EQUALS", "value": "cz0" } },
  { "filter": { "field": "device", "operation": "OP_EQUALS", "value": "192.0.2.10" } }
] } }

{ "or": { "clauses": [
  { "filter": { "field": "name", "operation": "OP_EQUALS", "value": "eth0" } },
  { "filter": { "field": "name", "operation": "OP_EQUALS", "value": "eth1" } }
] } }

{ "not": { "clause":
  { "filter": { "field": "source", "operation": "OP_EQUALS", "value": "cz0" } }
} }

{ "filter": { "field": "device", "operation": "OP_EQUALS", "value": "192.0.2.10" } }

{ "in": { "field": "device", "values": ["192.0.2.10", "192.0.2.11"] } }

{ "withIds": { "ids": ["AAAAAYcLE4UpjDUTWVU8_OnSvBQ="] } }

{ "range": { "path": "createdTime", "gte": 1784216459000, "lt": 1784302859000 } }

Response fields

Field

Description

metrics

An array of the metrics that matched the search.

metrics[].id

A string that uniquely identifies the metric.

metrics[].name

The display name of the metric.

metrics[].dictionary

An object that holds the metric's definition metadata. For its fields, see Dictionary fields.

metrics[].timestamps

An array of strings, each the time of one data point in milliseconds since the epoch (January 1, 1970 at 00:00:00 UTC).

metrics[].values

An array of numbers, each the value of the data point at the matching position in timestamps.

nextPageToken

The token that identifies the next page of results. The value is empty on the last page.

Dictionary fields

Field

Description

default

An object that holds the default version of a tenant-specific metric. The object takes the same form as dictionary. The value is null when the metric isn't tenant-specific.

defaultGroupingFields

An array of the fields used to group the metric for aggregation by default.

description

A long-form description of the metric.

isRate

A boolean that indicates whether to display the metric as a rate rather than as its raw cumulative value.

label

A short, human-readable label for the metric.

layer

The layer the metric definition comes from. Values:

  • DEFAULT: The global layer.

  • TENANT: The tenant-specific layer.

maximum

The highest likely value for the metric. The value is null when it isn't known.

minimum

The lowest likely value for the metric. The value is null when it isn't known.

name

The name that uniquely identifies the metric within its layer.

scaleFactor

The number that converts the time series data to the unit named in scaleFactorUnits. The value is null when it isn't known.

scaleFactorString

The string form of scaleFactor, which avoids the precision problems that can occur when the number is displayed.

scaleFactorUnits

The name of the unit that applies after scaleFactor is applied. The value is null when it isn't known.

tags

An array of arbitrary strings associated with the metric.

units

The unit of measure for the metric, such as bytes, percent, or milliseconds.

Response codes

Code

Description

200

The request was processed successfully. For operations on multiple objects, check the response body for per-item results.

400

The request couldn't be processed. The request body is missing, malformed, or contains invalid values.

401

Authentication failed. The API key is missing or invalid.

500

An unexpected error occurred. Try the request again. If the problem persists, contact Virtana support.

Examples

curl https://YOUR-API-ENDPOINT/v1/metrics:search \
  -H "content-type: application/json" \
  -H "zenoss-api-key: YOUR-API-KEY" \
  -X POST -s -S -d \
'{
  "entityClause": {
    "and": {
      "clauses": [
        {
          "filter": {
            "field": "source",
            "operation": "OP_EQUALS",
            "value": "cz0"
          }
        },
        {
          "filter": {
            "field": "device",
            "operation": "OP_EQUALS",
            "value": "192.0.2.10"
          }
        },
        {
          "filter": {
            "field": "name",
            "operation": "OP_EQUALS",
            "value": "br-232dcdc111e6"
          }
        }
      ]
    }
  },
  "timeRange": {
    "start": "2026-07-16T15:40:59.000Z",
    "end": "2026-07-17T15:40:59.000Z"
  },
  "downsample": {
    "aggregator": "MEAN",
    "period": "3600s"
  }
}'