Budget alerts

A budget's alerts mail people when its spend nears its limit, and post to the Slack channels admins add, so someone can raise the limit or find what is spending before Tidegate starts refusing reservations. Each budget has up to 10 alerts, of two kinds:

  • Spent: the window's spend has reached a percent of the limit, such as 80% or 100%.
  • Pace: at the rate it has spent so far this window, spend will reach a percent of the limit before the window resets. A pace alert at 100% warns that the budget will run out early, while there is still time to act.

A percent can be anything from 1% to 1000%: an alert past 100% says how far over its limit a budget's spend has gone, since settlements and price changes can take it past.

Only budgets of a day or longer

A budget whose windows are shorter than a day has no alerts, and can't be given any. By the time a mail is read, an hour's window has reset, and a rate limit's alerts would mail all day. Its denials, and the Budgets page, are where to watch it: its panel there says it has no alerts, and it has no Change alerts. A budget of daily, weekly, or monthly windows, or any window of a day or longer, can have them.

Where it all lives

WhatWhereWho changes it
A budget's alertsThe Budgets page: the budget's panel, and its row's menuAdmins, the API, and agents
The organization's addressAlerts, in SettingsAdmins; members see it
Slack channelsAlerts, in SettingsAdmins; members see them
Whether you get alertsYour account, in SettingsEach person, for themselves

Changing a budget's alerts

A new budget has two alerts: spent at 100%, and pace at 100%. Picking a budget on the Budgets page opens its panel, which lists its alerts, such as "80% spent · on pace for 120%". Admins change them with Change alerts, in the panel or the menu at the end of the budget's row: each alert is a kind, Spent or On pace for, and a percent of the limit, and Add alert and the × beside each add and remove them, up to 10. Saving replaces them all; saving none turns the budget's alerts off. The API and an agent change them too, and every change is recorded in the history, with the alerts before and after.

Each budget's bar on the Budgets page has a tick at how far through its window the budget is. Spend that fills the bar past the tick is ahead of an even pace: at that rate, it reaches the limit before the window resets, which is when a pace alert at 100% fires. Like the alert, the tick waits until a tenth of the window has passed. A split budget's bar is the value that has spent the most, and each value's bar under it has the same tick.

When an alert fires

Tidegate checks every budget's alerts about once a minute. An alert fires once per window: once it has mailed, it stays quiet until the next window starts, or until an admin changes the budget's limit, which arms it again. Several alerts firing in the same check, such as spent at 80% and pace at 100%, are one mail.

A budget split by a label has each value checked on its own, against the full limit, as reservations are: one mail lists every value that crossed, the 20 that spent most first, then how many more.

A pace alert waits until a tenth of the window has passed, so a burst in its first minutes doesn't project to many times the limit. Once spend has reached its percent, a pace alert stays quiet: the line is no longer ahead, and a spent alert at that percent is the one to say so.

A frozen or archived budget is never checked. Restored, it is checked again; an alert that crossed while it was archived fires then.

Who gets the mail

Alerts go to two kinds of recipient, each address once:

  • The organization's alert address, such as a team's mailing list, once someone there has confirmed it. Admins set it on the Alerts page, in Settings, under Alert address, where they also change it and remove it; members see it there too. Tidegate mails the address a link to confirm it, which works for 7 days; until someone follows it, the page says it is waiting for confirmation, nothing else is mailed there, and Resend link mails a new one (at most one a minute). An address gets at most 5 links a day, and an organization sends at most 10; past that, setting the address is refused until the next day, and the address before stays. Anyone who reads that address can confirm it, so it can be a list nobody in the organization is on. The link opens a page with a Confirm button, and nothing is confirmed until someone presses it, so a mail scanner that opens the link confirms nothing.
  • Members who want alerts, each with the switch "Email me budget alerts" in Your account, in Settings, which says whether they get them and why. Admins get them unless the organization has a confirmed alert address, since that is usually where they want alerts to go instead; members don't, unless they turn them on. Each person's choice is their own, and wins over either default; Use the default, below the switch, goes back to their role's. The choice is for the organization the pages show, so someone in several chooses in each.

Tidegate mails only people who have signed in at least once, so being added to an organization never means mail to an address nobody has used. A mail says why it was sent, and a member's says where to turn alerts off. It links to the budget on the Budgets page, which scrolls to it and marks it.

Where a Tidegate deployment sends no mail, the pages say so, budgets' alerts are kept but mail nobody, the switch in Your account can't be changed, and an organization can't set an alert address.

Slack channels

Alerts can also be posted to Slack channels, as many as you like, in one Slack workspace or several. Each channel gets either:

  • Every budget's alerts, including those of budgets defined later, or
  • Chosen budgets and apps: the alerts of the budgets you pick, and of every budget of the apps you pick, including budgets defined for those apps later. A budget of the whole organization belongs to no app, so pick it on its own.

So a team's channel and its on-call channel can both follow the team's app, while a channel for the whole organization follows everything. A post says what the mail says, links to the budget, and ends by saying why the channel gets it, with a link to change that.

To add one, an admin opens Alerts, in Settings, and chooses Add channel, picks what the channel gets, and chooses Continue to Slack. Slack asks which workspace and channel to post to, and whether to allow it; a workspace may need its own admin to approve Tidegate first. Slack then sends you back to Alerts, which says whether the channel was added. Tidegate posts a welcome in the channel straight away, so you can see it works. Finish within 10 minutes, in the same browser you started in, or start again. Adding a channel that is already there replaces what it gets.

Tidegate can post only to the channels admins chose this way, and can't read anything in Slack. Admins change what a channel gets, or remove it, from the menu at the end of its row; members see the channels and what each gets. Removing a channel stops the posts; to remove Tidegate from the channel in Slack as well, a Slack admin removes its integration there. Each addition, change, and removal is in the history.

If a channel stops getting posts, its row says Not posting, and why: the channel was archived or deleted, Tidegate was removed from the workspace, or the workspace doesn't allow the posts. Fix that in Slack, then add the channel again, which starts its posts again. A budget or app chosen for a channel that is later removed drops out of its choices; once none is left, the channel gets nothing, and its row says so.

Where a Tidegate deployment posts nothing to Slack, the Alerts page says so, and no channel can be added.

Setting alerts with the API

PUT /tenants/{tenant}/budgets/{id}/alerts sets a budget's alerts, replacing them all:

{
  "alerts": [
    { "kind": "spent", "percent": 80 },
    { "kind": "spent", "percent": 100 },
    { "kind": "pace", "percent": 100 }
  ]
}

It answers the budget's state, with its alerts sorted. It needs an admin, or a manager key, and refuses a budget whose windows are shorter than a day (422 AlertsNeedDailyWindows) unless the list is empty. An agent sets them with the set_budget_alerts tool. The alert address, Slack channels, and people's own settings are only on the pages, though the API reads the channels, at GET /tenants/{tenant}/slack-channels, and changes and removes them.