Metric commands: define, query, watch
The Metric Verbs define, query, watch as CLI commands, with inputs, result, refusals and an example.
Reference for Metric, one group of Metric commands.
Metric.define
Define compiles a Metric’s query against the Startup’s Events and Entries and lists every Event it reads. Verb page.
npx startup-builder do Metric.define --json '<input>' [--try | --send | --do]Emits Metric.defined.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
name | string | required | The Metric’s name. |
query | text | required | The query, over Events and Entries. |
unit | string | required | What one unit of it is. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
metric | Metric | required | The defined Metric. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
npx startup-builder do Metric.define --json '{"name": "Leaseline", "query": "Example query", "unit": "Example unit"}'Metric.query
Query reads Metrics or Events as a trend, funnel, retention curve, path or lifecycle, broken down by any property. Verb page.
npx startup-builder do Metric.query --json '<input>' [--try | --send | --do]Emits Metric.queried.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
metric | Metric | The Metric to read; omitted, the query names Events directly. | |
shape | string | required | The analysis to run. |
breakdown | string | The property to split by, such as an Organization or a Motion. | |
window | string | The time range, such as 30d. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
rows | json | required | The result rows, each number with its readability. |
metric | Metric | required | The Metric read. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
npx startup-builder do Metric.query --json '{"shape": "trend"}'Metric.watch
Watch alerts the owner of a Metric when it crosses a threshold, by a Task or a Message. Verb page.
npx startup-builder do Metric.watch --json '<input>' [--try | --send | --do]Emits Metric.watched.
Inputs
| Input | Type | Required | Description |
|---|---|---|---|
metric | Metric | required | The Metric to watch. |
threshold | number | required | The value that trips it. |
direction | string | required | Trip when the Metric goes above or below the threshold. |
Returns
| Output | Type | Required | Description |
|---|---|---|---|
watch | Watch | required | The Watch that checks it. |
metric | Metric | required | The Metric now watched. |
Refuses when
| Check | Error | Fix | Then call |
|---|---|---|---|
| The key is valid, but its scopes do not allow this operation. | forbidden | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
Example
npx startup-builder do Metric.watch --json '{"metric": "metric_GXFHAlK100", "threshold": 1, "direction": "above"}'