aggregate
Group the entities matching a CEL expression by the scalar
group_by expression and return one row per group, ranked by the
aggregate descending — a bounded roll-up, NOT per-entity fetch-and-tally.
aggregate is 'count' (default) or sum|avg|min|max applied to the
metric CEL expression (required for those). Examples:
aggregate("entity.type=='Well'", group_by="entity.state.status")
→ count of wells per status
aggregate("entity.type=='Well' && has_obs(entity,'gas_rate')",
group_by="entity.identity.field",
metric="latest(entity,'gas_rate')", aggregate='avg')
→ average current gas_rate per field
Bounded to a context-lookup roll-up: fixed aggregates, no joins, and a
hard group cap (a high-cardinality group_by errors — group by a
low-cardinality field or narrow the selection). format (json|tsv|md)
applies to the group rows.
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": {
"expression": "<expression>",
"group_by": "<group_by>"
},
"name": "aggregate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| types | No | ||
| format | No | json | |
| metric | No | ||
| group_by | Yes | ||
| aggregate | No | count | |
| expression | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||