query_range
Run time-window aggregation queries on non-metric tables using RANGE syntax, with alignment steps, group-by columns, fill strategies, and filters to summarize data over intervals.
Instructions
Execute time-window aggregation query using GreptimeDB's RANGE query syntax.
The narrowest of the three query entry points. Use it for a window
aggregation over a non-metric table, or an alignment PromQL cannot state;
a metric time series is better served by execute_tql and anything else by
execute_sql.
`select` must carry at least one aggregate with its own RANGE, such as
`avg(cpu) RANGE '5m'`, and `align` supplies the step between windows. A
plain column list does not plan. `table` accepts `schema.table` to read a
database other than the connected one.
A larger align lowers resolution; tighter filters or a lower limit return
a subset. An untruncated retry with those changes does not cover the
original query.
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": {
"table": "<table>",
"select": "<select>",
"align": "<align>"
},
"name": "query_range"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| by | No | Group by columns, e.g., 'host' | |
| fill | No | Fill strategy: NULL, PREV, LINEAR, or a value | |
| align | Yes | Alignment interval, e.g., '1m', '5m' | |
| limit | No | Maximum rows to return, clamped to 1-10000 | |
| table | Yes | Table name to query (supports schema.table format) | |
| where | No | WHERE clause conditions | |
| format | No | Output format: csv, json, or markdown (default: json) | json |
| select | Yes | Columns and aggregations, e.g., ts, host, avg(cpu) RANGE '5m' | |
| order_by | No | ORDER BY clause (e.g., 'ts DESC') |