set_metric

Type of operation: Metadata, Metrics

Description

Register a metric, with its metadata defined in an options object. name should be the expected value in the metric name field.

Usage

set_metric options, name

Argument

Type

Required

Multiple

options

options

Required

Only one

name

string

Required

Only one

Options

Option

Type

Meaning

type

string

Specifies the type of the metric. These types are supported: ‘cumulativeCounter’, ‘delta’, and ‘gauge’. It affects the behavior of certain alignment functions such as rate() and deriv().

unit

string

Specifies the unit of the metric. The unit will be displayed automatically on charts drawn from metric queries. It could be: ‘s’, ‘B’, ‘kB’, ‘MB’, ‘By’, ‘KiB’, ‘MiB’, etc. See the Metrics documentation for more information.

description

string

Specifies the description of the metric, shown in various places in the UI.

rollup

string

Specifies the default alignment method when plotting this metric. It could be: ‘avg’, ‘count’, ‘max’, ‘min’, ‘rate’, or ‘sum’.

aggregate

string

Specifies the default aggregation method when plotting this metric. It could be: ‘any’, ‘any_not_null’, ‘avg’, ‘count’, ‘count_distinct’, ‘count_distinct_exact’, ‘max’, ‘median’, ‘median_exact’, ‘min’, ‘stddev’, or ‘sum’.

interval

duration

Specifies the metric reporting interval. This helps Observe to generate more meaningful metric queries by setting the lookback window (frame(back: 5m)) accordingly.

label

string

Deprecated. It used to be a short string describing the metric, shown in various UI components. We now always use the metric name for those componenets to avoid confusion.

Accelerable

set_metric is always accelerable if the input is accelerable. A dataset that only uses accelerable verbs can be accelerated, making queries on the dataset respond faster.

Examples

set_metric options(type:"cumulativeCounter", unit:"bytes", description:"Ingress reported from somewhere", interval: 15s), "ingress_bytes"

Register the metric ingress_bytes within this dataset. The dataset must already implement the "metric" interface, for example with interface "metric" where the metric names are in field metric and metric values in field value.

set_metric options(type:"gauge", unit:"C", description:"Storage room B temperature", interval: 5m), "temp"

Register the metric temp within this dataset. The dataset must already implement the "metric" interface, for example with interface "metric" where the metric names are in field metric and metric values in field value.

Aliases

  • addmetric (deprecated)