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 252624c
Browse filesBrowse the repository at this point in the historyBrowse files
feat(webapp,sdk,core,cli): manage custom metric dashboards from the API
Custom metric dashboards can now be managed from code: list, create,
rename, replace and delete them and their widgets through the API, the
SDK and the MCP server.
```ts
import { query } from "@trigger.dev/sdk";
const dashboard = await query.dashboards.create({
title: "Email tasks",
widgets: [
{
title: "Total runs",
query: "SELECT count() AS total FROM runs WHERE task_identifier = 'send-email'",
display: { type: "bignumber", column: "total", aggregation: "sum" },
},
],
});
await query.dashboards.widgets.add(dashboard.id, {
title: "Failed runs",
query: "SELECT count() AS failed FROM runs WHERE status = 'Failed'",
display: { type: "bignumber", column: "failed", aggregation: "sum" },
});
```
How it works:
- New endpoints under `/api/v1/query/dashboards`: create, retrieve,
update, replace (the whole widget list, for dashboards as code), delete,
and add, update or delete a single widget. The existing list endpoint
now returns custom dashboards next to the built-in ones, with a `type`
field.
- `position` places a widget on the 12-column grid. On replace, a widget
that already exists keeps its position unless you pass a new one; new
widgets without a position are stacked full width below the others.
- Every widget query is compiled against the queryable tables when it is
saved, so an unknown table or column fails the request with the list of
valid columns.
- Writes take an optional `revision`. If the dashboard changed since
that revision was read, the write fails with a 409 instead of
overwriting the other change.
- Creating dashboards or widgets past the plan's limits returns a 403.
Concurrent creates can no longer exceed the dashboard limit.
- Reading needs `read:query`; changing dashboards needs `write:query`.
Public access tokens work, which is how the MCP tools authenticate.
- The MCP server adds `create_dashboard` and `set_dashboard_widgets`,
hidden in `--readonly`, and `run_dashboard_query` now runs custom
dashboard widgets too.
Mono-RevId: cee3a676407aecdaefa16724eea59c7fccab1563
Manage custom metric dashboards from code. `query.dashboards` lists, creates, updates and deletes custom dashboards and their widgets, and every widget query is checked when it is saved. The MCP server adds `create_dashboard` and `set_dashboard_widgets`, so your AI assistant can build a dashboard for you.
Copy file name to clipboardExpand all lines: apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.dashboards.custom.$dashboardId/route.tsx
0 commit comments