Alerts
When a number crosses your line, the people who care are told. An alert is a
watcher with one shape: a schedule, a query, a condition, and a
notify. It fires once when the condition starts holding and re-arms when it clears.
In the app
On a dashboard, click Watch, then Tell me when…. Write the query that returns one number (or the rows that should not exist), choose A number crosses a line or Any row matches, set the schedule and its time zone, and pick the members and the destinations to tell. Test runs it once and shows what each member would be told, without sending anything. The watcher then appears on the dashboard, under Watching this dashboard.
With the SDK and MCP
from vibedasher import Vibedasher
from vibedasher.models import WatcherCreate
client = Vibedasher()
alert = client.watchers.create(WatcherCreate.from_dict({
"name": "Revenue below 10k",
"title": "Daily revenue",
"triggers": [{"kind": "schedule", "params": {"cron": "0 7 * * *", "timezone": "Europe/Paris"}}],
"check": {"sql": "SELECT SUM(revenue) FROM orders WHERE order_date = CURRENT_DATE - 1",
"datasetIds": [42], "window": "none"},
"condition": {"kind": "threshold", "params": {"comparator": "lt", "value": 10000}},
"actions": [{"id": "tell", "kind": "notify",
"params": {"to": [{"member": "usr_1a2b3c"}], "vizId": 1430,
"message": "Revenue was {{check.value}} yesterday."}}],
}))
client.watchers.test(alert.id) # a dry run: sends nothing
const alert = await client.watchers.create({
name: 'Revenue below 10k',
title: 'Daily revenue',
triggers: [{ kind: 'schedule', params: { cron: '0 7 * * *', timezone: 'Europe/Paris' } }],
check: { sql: 'SELECT SUM(revenue) FROM orders WHERE order_date = CURRENT_DATE - 1', datasetIds: [42], window: 'none' },
condition: { kind: 'threshold', params: { comparator: 'lt', value: 10000 } },
actions: [{ id: 'tell', kind: 'notify', params: { to: [{ member: 'usr_1a2b3c' }], vizId: 1430, message: 'Revenue was {{check.value}} yesterday.' } }],
});
await client.watchers.test(alert.id);
Over MCP: create_watcher with the same fields, then test_watcher.
From the alert fields to the watcher fields
Alerts used to be written with five fields. Each one has a place on the watcher:
| Alert field | On the watcher |
|---|---|
when: the SQL that selects the breach | check.sql, with the condition rows (any row is a breach) or threshold (one number compared with value) |
say: the message | message on the notify action; it reads {{check.value}}, {{check.rows}}, {{check.prior}}, {{check.delta}} and {{firing.url}}; the fired row's columns as {{row.<column>}} ({region} in say is {{row.region}}), and a table of the rows as {{rows}} |
every: a cron or 15m / 2h / 1d | a schedule trigger: a 5-field cron and an IANA timezone (15m is */15 * * * *) |
capture: the picture of the breach, in Playwright | capture on a snapshot action before the notify, listed in the notify's attach: the same Playwright source, or the same steps as captureRecipe. A read returns both captureRecipe and capturePlaywright. {column} binds the row that fired: one picture per fired row, at most five |
to: who is told | to on the notify action: members by id, and destinations by id (an e-mail list, a Slack channel); a webhook has its own webhook action |
viewState: the page, dates and filters of the picture | viewState on the snapshot action |
| the backtest on create | client.watchers.test(id) / test_watcher: the check, the condition and every message, sent to nobody |
The capture, step by step
{"id": "snap", "kind": "snapshot", "params": {
"vizId": 1430,
"capture": "await page.goto('?page=overview&f.region={region}');\n"
"await expect(page.getByTestId('chart-rendered')).toBeVisible();\n"
"await page.locator('[data-capture-root]').screenshot();",
}}
The source is parsed into steps and never run as code. A step finds an element the way Playwright does, by role, text, label, placeholder, test id or CSS (getByRole('button', { name: 'West' }), getByLabel('Region'), locator('.kpi'), then .locator(), .nth(), .first(), .last(), .filter({ hasText })), and does one thing to it: click, dblclick, hover, check, uncheck, fill, press, selectOption, waitFor, screenshot (the picture is cropped to that element) or expect(...).toBeVisible(). page.goto('?…') sets the view through the address, and page.waitForTimeout(ms) waits at most five seconds. Arguments are literal strings, numbers and booleans; evaluate, a network route, a variable, a loop, a condition or an address on another site is refused with its line number. A capture has at most 40 steps. getByTestId('x') matches data-testid="x", or data-selector="x" when no data-testid does. {region} is a column the check returns: with the condition rows, each matching row gets its own picture of its own region, up to five per firing; with threshold, the check's one row. A column the check does not return is refused when you save, with the columns it does return. In a locator it stays a value: getByRole('row', { name: '{customer}' }).
The picture reaches every recipient: each member whose rows equal yours gets it as a file, and so do the destinations of the same notify, because everyone there sees what you see. That is the same act as sharing the dashboard, so a picture to a destination takes an owner who may share it. An e-mail list gets the file, Slack gets the image on a signed link that expires after a day, and a webhook action with attach gets the same link in its JSON.
Reaching the view
Prefer the address. A dashboard built with the @ds controls reads ?page=, ?date= and ?f.<filter>= itself, so viewState or page.goto('?f.region=West') pins the view before it paints, and the capture checks that the dashboard applied it: a filter the page did not apply fails the capture and names the filter. For a control the dashboard draws itself, find it by its role or its label and act on it.
test_watcher replays the capture in the browser, as you, and returns the picture and each step with its line and what it did (applied, found, acted, timed_out, failed). When the dashboard is published, every watcher that captures it is replayed against the new version, as its owner; one that no longer works is reported to the publisher and to its owner as "this change breaks watcher X at line N", and the publish goes ahead.
Limits
- Each member is evaluated as themselves. A member is told only what holds on the rows they can see, with their own value; a destination gets the message with only what you may share and the attached pictures, never a value computed on rows.
- A message says each reader's own rows.
{{row.<column>}}and{{rows}}are computed from each reader's own result; a destination gets your rows only when you may share every dataset the check reads. - It fires on the transition. One message when the condition starts holding, none while
it holds, and it re-arms when it clears.
"edge": "every"or"refireAfter": "7d"in the condition's params change that. - It runs as its owner, with the owner's access re-checked on every run. An alert whose owner can no longer read its data pauses itself and says why.
- A schedule runs at most every five minutes.
Reference
create-watcher,test-watcher,run-watcher,list-watcher-firings,list-watcher-kinds- The engine and every field: Watchers