---
updatedAt: 2026-10-21T20:53:38.000Z
agentTools:
  projectIndex: https://docs.observeinc.com/llms.txt
---

# Collect and use metrics

# Types of metrics collected by Observe by Snowflake

Metric type is used to drive default visualization behaviors in metric expression builders such as [Metrics Explorer](https://docs.observeinc.com/docs/metrics-explorer) or a [Threshold Metrics Monitor](https://docs.observeinc.com/docs/create-a-threshold-monitor#/metrics-explorer) . The metric type also affects the behavior of alignment function that are sensitive to metric types, such as [`rate`](https://docs.observeinc.com/docs/function-rate#/)  and [`delta`](https://docs.observeinc.com/docs/function-delta#/) .

<Callout icon="📘" theme="info">
  ### Note

  The Metric type drives default visualization behavior. If the default is not the desired behavior, you can easily switch the alignment functions in the expression builder: for instance, change [`avg()`](https://docs.observeinc.com/docs/function-avg#/) to [`rate()`](https://docs.observeinc.com/docs/function-rate#/) or change [`rate()`](https://docs.observeinc.com/docs/function-rate#/) to [`delta()`](https://gdocs.observeinc.com/docs/function-delta#/).
</Callout>

You can view the type of an ingested metrics dataset by hovering over the name in Metrics Explorer. It is useful to confirm that the type is set correctly, as false positive or negative results could occur from incorrectly typed metrics.

## Supported metric types

Observe by Snowflake supports the following metric types:

* gauge
* cumulativeCounter
* delta
* tdigest
* histogram
* exponentialHistogram

<Tabs>
  <Tab title="gauge">
    The `gauge` metric type represents a snapshot of the state at the time of collection. Use a `gauge` metric type to measure data that is reported continuously, such as available disk space or memory used. The value of a gauge metric can go up or down or stay the same.

    Given a series of memory measurements, such as `pod_memory_working_set_bytes` from [Kubernetes](../integrations/kubernetes/collecting_pod_metrics_cadvisor_metrics), an example data series might look like `31, 30.5, 31, 31, 31.5`.

    In a `gauge` metric of `pod_memory_working_set_bytes`, all reported values are retained. Query time parameters are then used to calculate and display what the user requires.
  </Tab>

  <Tab title="cumulativeCounter">
    The `cumulativeCounter` metric type represents a cumulative measurement that is measured since the creation of the time-series. The value can only increase (monotonically), or reset to zero when restarted.

    Given a series of CPU measurements, such as `pod_cpu_usage_seconds_total` as used in [Kubernetes](https://docs.observeinc.com/docs/kubernetes), the CPU measurements accumulated since the pod started. An example data series might look like `36.33, 36.61, 40.96, 652.20, 1097.59`.

    In a `cumulativeCounter` metric of `pod_cpu_usage_seconds_total`, all of the values are reported (`36.33, 36.61, 40.96, 652.20, 1097.59`).
  </Tab>

  <Tab title="delta">
    The `delta` metric type represents the value change since the last collected report. For example, if CPU utilization increased from 50% to 80% during a metric reporting interval, the delta metric reported for it would be 30%. The value of a delta metric can go up or down or stay the same.

    Given a series of memory measurements, such as `pod_memory_working_set_bytes` from [Kubernetes](https://docs.observeinc.com/docs/kubernetes), an example data series might look like `31, 30.5, 31, 31, 31.5`.

    In a `delta` metric of `pod_memory_working_set_bytes`, the first measurement is reported, followed by the delta at the end of the period (`31, 0.5`).
  </Tab>

  <Tab title="tdigest">
    The `tdigest` metric type contains data points that summarize multiple measurements in a single [tdigest](https://github.com/tdunning/t-digest) value. All points in the time series are independent (as for `gauge` metrics). This metric type is useful to calculate percentiles in a performant way.

    Suppose we have a dataset containing Span durations. After filtering the durations of only one Span we are interested in, we could summarize such span's durations into tdigest values at regular time intervals. Then, we could extract the n-th percentile at each point in the time series, effectively generating a plot of "n-th percentile duration of Span X".
  </Tab>

  <Tab title="histogram">
    One point summarizes many measurements in a classic OpenTelemetry histogram. Points in the series are independent, same as a gauge. Declare it with:

    ```
    interface "metric", metric:metric, value:value, objectValue:histogramValue
    set_metric options(type:"histogram"), "rpc_latency"
    ```

    Align and read a percentile with:

    ```
    align 1m, frame(back: 1m), o: histogram_combine(m_histogram("rpc_latency"))
    aggregate p99: histogram_quantile(histogram_combine(o), 0.99), group_by(^Cluster...)
    ```

    `m_histogram` selects this type. `m()` selects only `float64` metrics.
  </Tab>

  <Tab title="exponentialHistogram">
    Same idea as histogram, with exponential buckets. Declare it with `set_metric options(type:"exponentialHistogram"), "body_size"` and select it with [`m_exponential_histogram`](https://docs.observeinc.com/docs/function-m_exponential_histogram). [`histogram_combine`](https://docs.observeinc.com/docs/function-histogram_combine) and [`histogram_quantile`](https://docs.observeinc.com/docs/function-histogram_quantile) accept both representations.
  </Tab>
</Tabs>

## Set the metric type

The metric type can be explicitly set with [`set_metric`](https://docs.observeinc.com/docs/verb-set_metric). Whenever the metric type is not explicitly set, Observe by Snowflake tries to auto-assign a metric type. This is true for all `float64` metrics (`gauge`, `cumulativeCounter` and `delta`). Metrics of type `tdigest`, `histogram`, and `exponentialHistogram` can't be automatically discovered by Observe by Snowflake. Use `set_metric options(type:"tdigest"), "metric-name"` to get the correct metric visualization behavior for `tdigest`, `histogram`, and `exponentialHistogram` metrics.

Metric types do not affect how metric data is collected or stored, but they are used at query time. A metric is tabulated to make a chart or test a monitored condition. This requires a time resolution, which Observe by Snowflake dynamically determines based on your query window size. For instance, a query window of four hours would have a resolution of one minute; while a query window of one day will have a resolution of five minutes.

The chart or table's behavior is also established by using an OPAL **alignment function** . This is a mathematical operation used on the values in each time resolution window to determine which value to show in the table or chart. For instance, a metric might have points at every thirty seconds, while our chart has a five minute resolution. This means each five minute window has ten measurements to evaluate. The [`avg()`](https://docs.observeinc.com/docs/function-avg#/)  function will show the average of those ten values.

Metric types affect the run time behavior of some operations that use alignment functions .

* [`delta`](https://docs.observeinc.com/docs/function-delta#/) : calculates the value difference of the argument in each time bin for each group. [`delta`](https://docs.observeinc.com/docs/function-delta#/) may produce negative values when the argument decreases over time.
  * for **gauge** metrics, [`delta`](https://docs.observeinc.com/docs/function-delta#/) retains the default behavior. Negatives may be produced when the value is decreasing.
  * for **cumulativeCounter** metrics, [`delta`](https://docs.observeinc.com/docs/function-delta#/) will assume the values to be monotonically increasing, and treats decreasing values as counter resets. Negatives will not be produced for `cumulativeCounter` type metrics.
  * for **delta** metrics, [`delta`](https://gdocs.observeinc.com/docs/function-delta#/) will sum up the values in the time window to return the total sum. Negatives may be produced for negative input values.
* [`delta_monotonic`](https://docs.observeinc.com/docs/function-delta_monotonic#/) : calculates the amount of difference in a column in each time bin for each group. `delta_monotonic` by default assumes the argument to be monotonically increasing, and treats decreasing values as counter resets.
  * for **gauge** and **cumulativeCounter** metrics, [`delta_monotonic`](https://docs.observeinc.com/docs/function-delta_monotonic#/) retains the default behavior of assuming monotonic increases.
  * for **delta** metrics, [`delta_monotonic`](https://docs.observeinc.com/docs/function-delta_monotonic#/) will sum up the values in the time window to return the total sum. Negatives may be produced for negative input values.
* [`deriv`](https://docs.observeinc.com/docs/function-deriv#/) : calculates the average per-second derivative of the metric during each time frame
  * for **gauge** metrics, [`deriv`](https://docs.observeinc.com/docs/function-deriv#/) computes the value change over the time frame, allowing negative changes, and then divides the value change with time frame size.
  * for **cumulativeCounter** metrics, [`deriv`](https://docs.observeinc.com/docs/function-deriv#/) computes the value change over the time frame, treating value decreases as counter resets to prevent negative changes, and then divides it by the time frame size.
  * for **delta** metrics, [`deriv`](https://docs.observeinc.com/docs/function-deriv#/) computes the value change by summing up the deltas, and then divides it by the time frame size.
* [`rate`](https://docs.observeinc.com/docs/function-rate#/) : calculates the average per-second rate of increase of the metric during each time frame
  * for **gauge** and **cumulativeCounter** metrics, [`rate`](https://docs.observeinc.com/docs/function-rate#/) computes the value increase over the time frame, assuming monotonic increase in the value and treating decreasing values as counter resets, and then divides the value increase by the time frame size.
  * for **delta** metrics, [`rate`](https://docs.observeinc.com/docs/function-rate#/) computes the value increase by sums of the deltas, and then divides it by the time frame size.

`histogram` and `exponentialHistogram` metrics are not aligned with `rate`, `delta`, `deriv`, or `delta_monotonic`. Align them with [`histogram_combine`](https://docs.observeinc.com/docs/function-histogram_combine), then read a percentile with [`histogram_quantile`](https://docs.observeinc.com/docs/function-histogram_quantile).

# Understand aggregation

Aggregation is a computation that rearranges a time series into regular time intervals, aggregating multiple data points of a time series into one data point for each time interval.

## Aggregation along the time dimension (alignment)

Metrics are usually very dense (contain lots of measurements at a high frequency). It is often useful to visualize a metric over time at more user friendly intervals. For example, disk usage metrics might have one value every 5 seconds, and we might want to plot such usage over the Black Friday week. Therefore, the ideal plotting format would be to have disk usage summaries every 10 minutes.

A typical alignment operation looks like this:

<Image src="https://files.readme.io/3ae42688dfde84f9ffb8fba037737d2964da1e04b5b847dc91701edc59b77efa-Metrics_Alignment_Concept.png" align="center" border={true} />

You can see that each `cpu_usage_total` point is not exactly vertically aligned with each `disk_usage` point. Before we can aggregate the data, we take the three red points between 00:00 and 00:05 and average them on the 00:05 line, then take the four blue points between 00:00 and 00:05 and average them on the 00:05 line. This is repeated for each interval, so we now have alignment on the average values.

In addition to using [`avg()`](https://docs.observeinc.com/docs/function-avg) for alignment, you can also use other functions, such as the following:

* Use [`last()`](https://docs.observeinc.com/docs/function-last) to mimick the default behavior for Prometheus. This function uses just the last point in each interval for alignment, and drops the other values.
* Use [`max()`](https://docs.observeinc.com/docs/function-max) to take only the largest or highest value in each interval for alignment.
* Use [`min()`](https://docs.observeinc.com/docs/function-min) to take only the smallest or least value in each interval for alignment.
* For cumulative counter metrics, use [`rate()`](https://docs.observeinc.com/docs/function-rate) or [`deriv()`](https://docs.observeinc.com/docs/function-deriv) to view the rate over time, such as the number of requests per second, and [`delta_monotonic()`](https://docs.observeinc.com/docs/function-delta_monotonic) or [`delta()`](https://docs.observeinc.com/docs/function-delta) to view the absolute change in value between the first point and last point, regardless of time.

A more advanced version of alignment is sliding window alignment, also known as hopping window alignment. It is used for computations like “rolling average”. In this query, for each time-series, we generate one output point every 5 minutes, by computing the average of the input points in the prior 10 minutes. For example:

<Image src="https://files.readme.io/0d327304ed25c5d5d4ec9bb526f35bf2166691ff095e515d991116aaf109fddc-Metrics_Alignment_Sliding_Window.png" align="center" border={true} />

## Aggregation along other dimensions

Time series can be aggregated across tags. For instance, consider the same metric **disk\_usage** being reported for different usage types, such as **free** or **used**. You can add them up to get the total disk space.

To accomplish this, use a tag-dimension aggregation operation that aggregates multiple (**already aligned**) time series into one. Tag-dimension aggregation takes in regularly aligned time series, and keeps the timestamps unchanged. Aggregation across tags also requires an aggregation function to be specified.

Conceptually, tag-dimension aggregation looks like this:

<Image src="https://files.readme.io/cbc987fd6585b53706b8461770644390bf0cb8d9034dde1c9a92132427e514f4-Metrics_Alignment_Aggregation.png" align="center" border={true} />

# Additional metrics metadata

In addition to the metric type, the following metadata items can be set:

* **Measurement type** - describes the type of data reported in each data point. Observe by Snowflake supports `float64`, `tdigest`, and `object` as metric data types.
* **Unit** - describes the unit of measurement such as `kb` or `kB/s`.
* **Description** - detailed information about the metric.
* **Tags** - For a time series, tags better describe and differentiate the measurements. You can use them to identify individual times series during metric computations such as [`align`](https://docs.observeinc.com/docs/verb-align#/) and [`aggregate`](https://docs.observeinc.com/docs/verb-aggregate#/).

<Image src="https://files.readme.io/14cd050a6eb56d22594ecb212bfe56537668dce37d89351c9fd5d74c05c64283-Metrics_Pod_Dashboard.png" align="center" border={true} />

A **Metrics Dataset** contains metric data recognized by Observe by Snowflake. Observe by Snowflake optimizes the metric dataset for scalable ingestion and queries, supporting a large number of metrics. A metric dataset has the following properties:

* Each row in the dataset table describes one point in a time series.
* A metric dataset contains a `string` type metric value column named `metric`.
* Contains a `float64` metric value column named `value`.
* Contains a `valid_from` column with the measurement time for each data point.
* The `metric` interface OPAL language designates a dataset as a metric dataset.
* All non-metric names, values, and non-valid\_from columns contain metric tags.

A **Metrics Dataset** is always an Event Dataset and the data either inherited from an upstream **Metrics Dataset** or created using the OPAL [`interface`](https://docs.observeinc.com/docs/verb-interface#/) verb. Metrics use OPAL in a worksheet to transform the raw data, add metadata, and create relationships between datasets. If you are not familiar with OPAL, please see [What is OPAL?](https://docs.observeinc.com/docs/what-is-opal#/)

A metric dataset contains one metric point per row - a single data point containing a timestamp, name, value, and zero or more tags. For example, the following table contains values for two metrics:

| valid\_from | metric             | value    | tags                |
| ----------- | ------------------ | -------- | ------------------- |
| 00:00:00    | disk\_used\_bytes  | 20000000 | `{"device":"sda1"}` |
| 00:00:00    | disk\_total\_bytes | 50000000 | `{"device":"sda1"}` |
| 00:01:00    | disk\_used\_bytes  | 10000000 | `{"device":"sda1"}` |
| 00:01:00    | disk\_total\_bytes | 50000000 | `{"device":"sda1"}` |
| 00:02:00    | disk\_used\_bytes  | 40000000 | `{"device":"sda1"}` |
| 00:02:00    | disk\_total\_bytes | 50000000 | `{"device":"sda1"}` |

Some systems generate this by default, or you can shape other data into the correct form with OPAL.

Metric values must be `float64`, `tdigest`, or an object (`histogram` or `exponentialHistogram`). If you need to convert numeric types to `float64` see the [`float64`](https://docs.observeinc.com/docs/function-float64#/) function. To create `tdigest` objects, use the [`tdigest_agg`](https://docs.observeinc.com/docs/function-tdigest_agg#/) function. To combine `tdigest` states in any dimension, use the [`tdigest_combine`](https://docs.observeinc.com/docs/function-tdigest_combine#/) function.

| input                               | function          | output                   |
| ----------------------------------- | ----------------- | ------------------------ |
| single numeric values               | `float64`         | `float64` numeric values |
| array of numeric or duration values | `tdigest_agg`     | `tdigest` JSON object    |
| multiple `tdigest` objects          | `tdigest_combine` | `tdigest` JSON object    |

`tdigest`, `histogram`, and `exponentialHistogram` values can't be stored in the **value** column, because that column is `float64`. A metrics dataset can also have a **tdigestValue** column for `tdigest` metrics and an **objectValue** column for `histogram` and `exponentialHistogram` metrics:

| valid\_from | metric                      | value    | tdigestValue                                             | objectValue                                                              | tags                     |
| ----------- | --------------------------- | -------- | -------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------ |
| 00:00:00    | disk\_used\_bytes           | 20000000 | null                                                     | null                                                                     | `{"device":"sda1"}`      |
| 00:00:00    | disk\_downtime\_nanoseconds | null     | `{"type":"tdigest","state":[15,1],"version":1}`          | null                                                                     | `{"device":"sda1"}`      |
| 00:00:00    | rpc\_latency                | null     | null                                                     | `{"explicit_bounds":[1,10],"bucket_counts":[3,7,1],"count":11,"sum":42}` | `{"service":"checkout"}` |
| 00:01:00    | disk\_used\_bytes           | 10000000 | null                                                     | null                                                                     | `{"device":"sda1"}`      |
| 00:01:00    | disk\_downtime\_nanoseconds | null     | `{"type":"tdigest","state":[15,1,30,1,2,1],"version":1}` | null                                                                     | `{"device":"sda1"}`      |
| 00:01:00    | rpc\_latency                | null     | null                                                     | `{"explicit_bounds":[1,10],"bucket_counts":[2,5,4],"count":11,"sum":68}` | `{"service":"checkout"}` |
| 00:02:00    | disk\_used\_bytes           | 40000000 | null                                                     | null                                                                     | `{"device":"sda1"}`      |
| 00:02:00    | disk\_downtime\_nanoseconds | null     | `{"type":"tdigest","state":[],"version":1}`              | null                                                                     | `{"device":"sda1"}`      |
| 00:02:00    | rpc\_latency                | null     | null                                                     | `{"explicit_bounds":[1,10],"bucket_counts":[1,4,6],"count":11,"sum":81}` | `{"service":"checkout"}` |

Each metric point populates exactly one of **value**, **tdigestValue**, or **objectValue**. The other two are null. Each row is one point in one time series.

* `disk_used_bytes` is a `float64` metric and uses **value**.&#x20;
* `disk_downtime_nanoseconds` is `tdigest` and uses **tdigestValue**.&#x20;
* `rpc_latency` is `histogram` and uses **objectValue**. An `exponentialHistogram` metric uses **objectValue** as well.