Vercel: checks and maintenance

Do the Vercel setup first.

Scheduled checks on recent data

Cron job
*/5 * * * *
GET
Vercel function
/api/cron/check
query
Tigris bucket
iot.readings
alert
Webhook
Slack, Teams, …

The check route runs every 5 minutes and asks two questions of the table:

  • Which pumps averaged above 80° over the last 10 minutes? A SQL query over recent data. The time filter skips every file whose time range lies outside the window, before any data is read.
  • Which pumps have sent nothing for 15 minutes? lake.latest() answers from the last-value index, without scanning the table.

When either has an answer, it posts a JSON message with a text field to ALERT_WEBHOOK_URL, the format Slack and Teams incoming webhooks accept. Change the SQL to check anything the table holds; over longer windows, a rollup keeps the query small.

Vercel doesn't retry a failed cron run, and may occasionally run one twice or let two overlap. Every job here is safe to repeat: the drain claims each message once, the landing job skips files already loaded, and a repeated check sends the alert again.

Maintenance

Each append already merges small files and removes duplicates. The hourly maintain job also sorts each finished day into one file, applies retention, and deletes files no version needs. To run it by hand:

curl $URL/api/cron/maintain -H "authorization: Bearer $CRON_SECRET"