query_metric
Compute governed business metrics with optional grouping, filters, and time buckets, returning the SQL and models used for provenance instead of relying on ad hoc SQL.
Instructions
Compute a governed metric, optionally grouped, filtered and bucketed by time.
Prefer this over run_sql: the metric definition is the agreed business logic. The result includes the SQL that ran and the models it read, for provenance.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"metric": "<metric>"
},
"name": "query_metric"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum rows, up to the server's row cap. | |
| metric | Yes | Metric name from list_metrics, e.g. 'on_time_rate'. | |
| filters | No | Filters on dimensions. | |
| end_date | No | Inclusive end date, YYYY-MM-DD. | |
| group_by | No | Dimensions to group by, as 'model.column' or a bare column name. | |
| order_by | No | Output column to sort by; defaults to the metric. | |
| descending | No | ||
| start_date | No | Inclusive start date, YYYY-MM-DD. | |
| time_grain | No | Bucket the metric by the base model's time column. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | ||
| rows | Yes | ||
| models | Yes | ||
| columns | Yes | ||
| query_id | Yes | ||
| warnings | No | ||
| row_count | Yes | ||
| truncated | Yes | ||
| elapsed_ms | Yes | ||
| catalog_version | Yes |