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.
You can explicitly provide or override a unit for a metric. You may use the full unit names, or common abbreviations. Most unit names can be referenced with the singular term (example: hour
) or plural term (example: hours
). You can combine names with a slash character for compound units like rates and ratios (example: gigabytes/hour
).
Usage¶
set_metric options, name
Argument |
Type |
Optional |
Repeatable |
Restrictions |
---|---|---|---|---|
options |
options |
no |
no |
constant |
name |
string |
no |
no |
none |
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 |
unit |
string |
Specifies the unit of the metric. The unit will be displayed automatically on charts drawn from metric queries. See Units of Measure for unit names, abbreviations, and rules. |
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’. ‘avg’ is the default alignment method for ‘gauge’ metrics, and ‘rate’ is the default alignment method for ‘cumulativeCounter’ and ‘delta’ metrics. |
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’. ‘sum’ is the default aggregation method. |
interval |
duration |
Specifies the metric reporting interval. This helps Observe to generate more meaningful metric queries by setting the lookback window ( |
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 components 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
.
set_metric options(type:"cumulativeCounter"), "cpu_used_total"
Register the cumulativeCounter metric cpu_used_total
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
. The cpu_used_total
will have rate()
as its default alignment method and sum()
as its default aggregation method.
Aliases¶
addmetric
(deprecated)