---
updatedAt: 2026-09-08T20:26:09.000Z
agentTools:
  projectIndex: https://docs.observeinc.com/llms.txt
---

# Get dataset attribute statistics

Returns aggregated statistics — distinct value count and the top-K
most frequent value/count pairs — for one or more dataset
attributes, optionally restricted to a CEL-filtered subset of
datasets.

Each `attributes` entry is a CEL expression that produces a
comparable value (string, int, bool, timestamp); compound
expressions are allowed (`coalesce(_package, label)`). The CEL
environment matches `GET /v1/datasets`; see that endpoint's
description for the field mapping, type discrepancies, and
available functions.

Each `multiValueAttributes` entry is a CEL expression that produces
a `list<comparable>`; the list is flattened across all matching
datasets and counted as **total occurrences**, so a single
dataset whose expression evaluates to a 3-element list
contributes 3 increments. `multiValueAttributes` `count` values may
therefore exceed `meta.filteredDatasets`. For `attributes` the
count is unchanged: the number of *datasets* with that value.

At least one of `attributes` or `multiValueAttributes` must be
non-empty; passing neither returns 400.

Stat values are returned as JSON strings regardless of the
expression's CEL type:

- `string` — verbatim.
- `int` — decimal digits (e.g. `"41000234"`).
- `bool` — `"true"` or `"false"`.
- `timestamp` — RFC 3339 (e.g. `"2024-01-01T00:00:00Z"`).

The response `meta` block reports `totalDatasets` (before the
filter) and `filteredDatasets` (after) so callers can compute
coverage.


# OpenAPI definition

````json
{
  "openapi": "3.1.0",
  "info": {
    "title": "Observe by Snowflake API",
    "description": "# Overview\nWelcome to the Observe API Docs!\n\nThe Observe API is a RESTful API. POST bodies and responses are typically JSON-encoded.\n\n## Authentication\nRequests to the Observe API are authenticated with an API token. The token can be supplied using HTTP Bearer authentication:\n```\n// passing token as bearer token\ncurl -H \"Authorization: Bearer <customerid> <token>\" https://<customerid>.<observe-domain>.com/v1/...\n```\n",
    "version": "1.0.230307"
  },
  "servers": [
    {
      "url": "https://{customerid}.observeinc.com",
      "description": "US west server",
      "variables": {
        "customerid": {
          "default": "OBSERVE_CUSTOMERID",
          "description": "The customer ID for your instance."
        }
      }
    },
    {
      "url": "https://{customerid}.{cluster}.observeinc.com",
      "description": "Specific regional cluster (prod)",
      "variables": {
        "customerid": {
          "default": "OBSERVE_CUSTOMERID",
          "description": "The customer ID for your instance."
        },
        "cluster": {
          "enum": [
            "eu-1",
            "ap-1"
          ],
          "default": "eu-1",
          "description": "For regional clusters, choose one."
        }
      }
    },
    {
      "url": "https://{customerid}.{domain}.com",
      "description": "Specific Observe server",
      "variables": {
        "customerid": {
          "default": "OBSERVE_CUSTOMERID",
          "description": "The customer ID for your instance."
        },
        "domain": {
          "default": "OBSERVE_DOMAIN",
          "description": "The Observe domain for your instance."
        }
      }
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Dataset",
      "description": "Manage datasets. Learn more about [datasets](https://docs.observeinc.com/en/latest/content/reference/ObserveKeyConcepts.html#datasets)..\n"
    }
  ],
  "paths": {
    "/v1/datasets/stats": {
      "get": {
        "summary": "Get dataset attribute statistics",
        "description": "Returns aggregated statistics — distinct value count and the top-K\nmost frequent value/count pairs — for one or more dataset\nattributes, optionally restricted to a CEL-filtered subset of\ndatasets.\n\nEach `attributes` entry is a CEL expression that produces a\ncomparable value (string, int, bool, timestamp); compound\nexpressions are allowed (`coalesce(_package, label)`). The CEL\nenvironment matches `GET /v1/datasets`; see that endpoint's\ndescription for the field mapping, type discrepancies, and\navailable functions.\n\nEach `multiValueAttributes` entry is a CEL expression that produces\na `list<comparable>`; the list is flattened across all matching\ndatasets and counted as **total occurrences**, so a single\ndataset whose expression evaluates to a 3-element list\ncontributes 3 increments. `multiValueAttributes` `count` values may\ntherefore exceed `meta.filteredDatasets`. For `attributes` the\ncount is unchanged: the number of *datasets* with that value.\n\nAt least one of `attributes` or `multiValueAttributes` must be\nnon-empty; passing neither returns 400.\n\nStat values are returned as JSON strings regardless of the\nexpression's CEL type:\n\n- `string` — verbatim.\n- `int` — decimal digits (e.g. `\"41000234\"`).\n- `bool` — `\"true\"` or `\"false\"`.\n- `timestamp` — RFC 3339 (e.g. `\"2024-01-01T00:00:00Z\"`).\n\nThe response `meta` block reports `totalDatasets` (before the\nfilter) and `filteredDatasets` (after) so callers can compute\ncoverage.\n",
        "operationId": "GetDatasetStats",
        "tags": [
          "Dataset"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "filter",
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "CEL expression restricting which datasets contribute to the\nstatistics. Must evaluate to `bool`. Must be URL-encoded.\nIf omitted, statistics are computed across all readable\ndatasets. See `GET /v1/datasets` for the CEL primer and\nfilter examples.\n"
          },
          {
            "in": "query",
            "name": "attributes",
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "CSV list of CEL expressions, each producing a comparable\nvalue (string, int, bool, timestamp). Each expression\nidentifies one stat to compute over the filtered dataset\nset. Maximum 10 expressions per request. See the operation\ndescription for the wire format of stat values.\n\nEither `attributes` or `multiValueAttributes` must be non-empty;\nboth may be supplied together.\n\nCSV-escape first, then URL-encode. Wrap an item in `\"` if it\ncontains a comma or `\"`; double a literal `\"` to `\"\"` inside\na quoted item.\n"
          },
          {
            "in": "query",
            "name": "multiValueAttributes",
            "schema": {
              "type": "string"
            },
            "required": false,
            "description": "CSV list of CEL expressions, each producing a `list<comparable>`\n(e.g. `interfaces.map(i, i.path)`, `correlationTags.map(t, t.tag)`,\n`primaryKey`, `fieldList.map(f, f.name)`). For each matching\ndataset, the expression's list is flattened into a per-expression\nbag and counts are total occurrences — a single dataset\ncontributes one increment per element. The flattened bag for\neach expression is capped at 10,000 values across all matching\ndatasets; exceeding the cap returns 400.\n\nMaximum 10 expressions. Either `attributes` or `multiValueAttributes`\nmust be non-empty; both may be supplied together. `topK`\napplies independently to each entry of either array.\n\nCSV-escape first, then URL-encode. Wrap an item in `\"` if it\ncontains a comma or `\"`; double a literal `\"` to `\"\"` inside\na quoted item.\n"
          },
          {
            "in": "query",
            "name": "topK",
            "schema": {
              "type": "integer",
              "format": "int64",
              "minimum": 1,
              "maximum": 100
            },
            "required": true,
            "description": "Number of top values to return per attribute, sorted by count\ndescending. Range 1–100. The total distinct count for each\nattribute is always reported via `distinctCount`, even when it\nexceeds `topK`.\n"
          }
        ],
        "responses": {
          "200": {
            "description": "Dataset statistics retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Dataset-StatsResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/ErrorResponse-400"
          },
          "401": {
            "$ref": "#/components/responses/ErrorResponse-401"
          },
          "403": {
            "$ref": "#/components/responses/ErrorResponse-403"
          },
          "429": {
            "$ref": "#/components/responses/ErrorResponse-429"
          },
          "5XX": {
            "$ref": "#/components/responses/ErrorResponse-5XX"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "Authorization: Bearer <customerid> <apitoken>\n"
      }
    },
    "schemas": {
      "ErrorMessage": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "description": "A stable, machine-readable identifier for the kind of error."
          },
          "message": {
            "type": "string",
            "description": "Error message"
          }
        },
        "required": [
          "type",
          "message"
        ]
      },
      "StatValueCount": {
        "title": "StatValueCount",
        "type": "object",
        "description": "One distinct attribute value and the number of rows carrying it.",
        "required": [
          "value",
          "count"
        ],
        "properties": {
          "value": {
            "type": "string",
            "description": "The attribute value, always a JSON string regardless of the expression's\nunderlying type. Strings appear verbatim; ints as decimal digits (e.g.\n`\"41000234\"`); bools as `\"true\"` or `\"false\"`; timestamps as RFC 3339\n(e.g. `\"2024-01-01T00:00:00Z\"`).\n"
          },
          "count": {
            "type": "integer",
            "format": "int64",
            "description": "Number of rows with this value."
          }
        }
      },
      "AttributeStats": {
        "title": "AttributeStats",
        "type": "object",
        "description": "Aggregated statistics for one requested attribute expression: how many\ndistinct values it produced, plus the most frequent value/count pairs.\n",
        "required": [
          "attribute",
          "distinctCount",
          "stats"
        ],
        "properties": {
          "attribute": {
            "type": "string",
            "description": "The attribute expression that was queried, verbatim from the request."
          },
          "distinctCount": {
            "type": "integer",
            "format": "int64",
            "description": "Total distinct values, including those outside the returned top-K."
          },
          "stats": {
            "type": "array",
            "description": "Top-K value/count pairs, sorted by count descending.",
            "items": {
              "$ref": "#/components/schemas/StatValueCount"
            }
          }
        }
      },
      "Dataset-StatsMeta": {
        "title": "DatasetStatsMeta",
        "type": "object",
        "required": [
          "totalDatasets",
          "filteredDatasets"
        ],
        "properties": {
          "totalDatasets": {
            "type": "integer",
            "format": "int64",
            "description": "Total number of datasets before applying filter"
          },
          "filteredDatasets": {
            "type": "integer",
            "format": "int64",
            "description": "Number of datasets after applying filter (equal to totalDatasets when no filter)"
          }
        }
      },
      "Dataset-StatsResponse": {
        "title": "DatasetStatsResponse",
        "type": "object",
        "description": "Aggregated stats for requested dataset attributes",
        "required": [
          "attributes",
          "multiValueAttributes",
          "meta"
        ],
        "properties": {
          "attributes": {
            "type": "array",
            "description": "One entry per requested `attributes` expression, in request\norder. Empty array if `attributes` was empty in the request.\n",
            "items": {
              "$ref": "#/components/schemas/AttributeStats"
            }
          },
          "multiValueAttributes": {
            "type": "array",
            "description": "One entry per requested `multiValueAttributes` expression, in\nrequest order. Empty array if `multiValueAttributes` was empty in\nthe request. Each entry's `count` values are total\noccurrences across all matching datasets and may exceed\n`meta.filteredDatasets`.\n",
            "items": {
              "$ref": "#/components/schemas/AttributeStats"
            }
          },
          "meta": {
            "$ref": "#/components/schemas/Dataset-StatsMeta"
          }
        }
      }
    },
    "responses": {
      "ErrorResponse-400": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorMessage"
            }
          }
        }
      },
      "ErrorResponse-401": {
        "description": "Unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorMessage"
            }
          }
        }
      },
      "ErrorResponse-403": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorMessage"
            }
          }
        }
      },
      "ErrorResponse-429": {
        "description": "Rate limit reached",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorMessage"
            }
          }
        }
      },
      "ErrorResponse-5XX": {
        "description": "Internal server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorMessage"
            }
          }
        }
      }
    }
  }
}
````