You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ca21249
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/observability/query.mdx
+5-14Lines changed: 5 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ The `metrics` table also records how the API rate limiter treated requests made
42
42
-`api.rate_limit.limit.per_second` (`gauge`): the sustained rate your limit refills at, in requests per second
43
43
-`api.rate_limit.limit.burst` (`gauge`): the most requests the limit admits at once
44
44
45
-
These rows have no run, task, or machine attributes (`run_id`, `task_identifier`, `machine_id` and so on are empty). Sum the counters over time, take `min()` of `api.rate_limit.remaining_min` and `max()` of the limit gauges. Total attempts in a bucket are `allowed + denied`. To draw the sustained limit for a bucket, multiply `api.rate_limit.limit.per_second` by that bucket's width in seconds; `timeBucket()` picks its width from the query's time range, so use a fixed `toStartOfMinute(bucket_start)` grouping when you want a known width (recording buckets never straddle a minute, so this grouping never splits a bucket; the example assumes a bucket width of at most one minute, which includes the default 10 seconds, and with a wider width you would group by that width and multiply by it instead). The limit gauges only exist in buckets that saw requests, and they follow any change to your limit, so a chart stays correct after an increase. Requests from preview branches share the parent preview environment's rate limit bucket and are recorded against that environment, so query at project scope to see them. Self-hosted instances enable recording with `API_RATE_LIMIT_METRICS_ENABLED=1`, or `allowlist` to record only organizations with the `apiRateLimitMetricsEnabled` feature flag.
45
+
These rows have no run, task, or machine attributes (`run_id`, `task_identifier`, `machine_id` and so on are empty). Sum the counters over time, take `min()` of `api.rate_limit.remaining_min` and `max()` of the limit gauges. Total attempts in a bucket are `allowed + denied`. To draw the sustained limit for a bucket, multiply `api.rate_limit.limit.per_second` by that bucket's width in seconds; `timeBucket()` picks its width from the query's time range, so use a fixed `toStartOfMinute(bucket_start)` grouping when you want a known width (recording buckets never straddle a minute, so this grouping never splits a bucket; the example assumes a bucket width of at most one minute, which includes the default 10 seconds, and with a wider width you would group by that width and multiply by it instead). The limit gauges only exist in buckets that saw requests, and they follow any change to your limit, so a chart stays correct after an increase. Requests from preview branches share the parent preview environment's rate limit bucket and are recorded against that environment, so query them from the dashboard's Query page at project scope. Self-hosted instances enable recording with `API_RATE_LIMIT_METRICS_ENABLED=1`, or `allowlist` to record only organizations with the `apiRateLimitMetricsEnabled` feature flag.
const result =awaitquery.execute("SELECT COUNT(*) as count FROM runs", {
153
-
// Scope: "environment" (default), "project", or "organization"
154
-
scope: "project",
153
+
// Scope: "environment" (default). With an API key every scope reads the key's environment.
154
+
scope: "environment",
155
155
// Time period using shorthand (e.g., "7d", "30d", "1h")
156
156
period: "7d",
157
157
// Or use explicit time range
@@ -464,18 +464,9 @@ LIMIT 100
464
464
465
465
## Query scopes
466
466
467
-
Control what data your query can access:
467
+
With an API key (the SDK or the REST API), a query reads the key's own environment. The default `scope` is `environment`, and that is what a `project` or `organization` scope runs at too.
468
468
469
-
-**`environment`** (default) - Query runs in the current environment only
470
-
-**`project`** - Query runs across all environments in the project
471
-
-**`organization`** - Query runs across all projects in the organization
472
-
473
-
```typescript
474
-
// Query across all environments in a project
475
-
const result =awaitquery.execute("SELECT environment, count() FROM runs GROUP BY environment", {
476
-
scope: "project",
477
-
});
478
-
```
469
+
To query across all environments in a project, or across all projects in the organization, use the **Query** page in the dashboard and pick the scope there.
Copy file name to clipboardExpand all lines: docs/v3-openapi.yaml
+1-2Lines changed: 1 addition & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1480,7 +1480,6 @@ paths:
1480
1480
const result = await query.execute(
1481
1481
"SELECT COUNT(*) as count FROM runs WHERE status = 'Failed'",
1482
1482
{
1483
-
scope: "project", // Query across all environments
1484
1483
period: "7d", // Last 7 days
1485
1484
format: "json"
1486
1485
}
@@ -8500,7 +8499,7 @@ components:
8500
8499
type: string
8501
8500
enum: ["environment", "project", "organization"]
8502
8501
default: "environment"
8503
-
description: The scope of data to query - environment (default), project, or organization
8502
+
description: The scope of data to query. With an API key, every scope reads the key's own environment. Project and organization wide queries are available on the dashboard's Query page.
0 commit comments