Lesson 3 of 3 Cost in the Engineering Workflow

Budgets, Alerts and Anomaly Automation

Fast detection limits the damage of cost mistakes. This lesson explains how budgets and forecast alerts work, how anomaly detection finds unexpected spend, how alerts should be routed and tuned, and how budget actions can respond automatically.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe budgets and forecast-based alerts.
  • Explain when budget actions are appropriate.
  • Compare budget alerts with anomaly detection.
  • Describe how to route and tune cost alerts.
  • Describe the steps of an anomaly response.

Budgets

A budget in a cloud cost tool sets an expected amount for a scope, such as an account, a service, a tag value or a team, over a period, usually a month. Notifications are sent when actual spend reaches thresholds, such as 50%, 80% and 100%, and, more usefully, when forecast spend for the period is expected to exceed the budget, which gives warning before the money is spent.

Budgets in cost tools are monitoring tools, not the organization's financial budget; they should be set from that budget or from the team's forecast so that alerts are meaningful.

Budget actions

Some services can take an action when a budget threshold is reached, for example applying a restrictive policy that prevents new resources, or stopping specific instances. AWS Budgets supports actions that apply IAM or service control policies or stop selected EC2 and RDS instances; Azure budgets can trigger action groups that run automation. Budget actions suit sandbox and development accounts, where stopping work is acceptable, but are rarely appropriate for production, where stopping services would cause an outage.

Anomaly detection

Budgets catch overspend relative to a fixed amount, but a runaway job in a large account may not cross a monthly budget threshold until weeks later. Anomaly detection learns the normal pattern of spend for a scope, including weekly cycles, and alerts when spend deviates significantly, often within a day. AWS Cost Anomaly Detection, Azure cost anomaly alerts and Google Cloud anomaly detection are native examples; FinOps platforms provide their own.

The following comparison sets out how budgets and anomaly detection complement each other.

Budget alerts
What triggers itActual or forecast spend crossing a set amount
Best at catchingGradual overspend against plan
SetupRequires an amount per scope
Choose when Tracking spend against an agreed plan
Anomaly detection
What triggers itSpend deviating from its learned pattern
Best at catchingSudden spikes, such as runaway jobs or misconfigurations
SetupLearns automatically; needs thresholds for alerting
Choose when Catching unexpected changes quickly

The following diagram shows a weekend timeline and when each control reacts.

Why anomaly detection catches a runaway cost faster than a budget alert. A job that retries endlessly from a Friday evening adds a large hourly cost, but a 100% alert on a large monthly budget may not fire for days or weeks. Anomaly detection flags the deviation within about a day; routed to the on-call engineer, the job stops early in the weekend instead of on Monday.
The alert time is approximate.
True or false

Anomaly detection

Exam skills 8.2.3

Check what cost anomaly detection can and cannot do.

Log in to try this activity Interactive activities are free with an account.

Routing alerts

An alert is only useful if someone who can act receives it promptly. Alerts should be routed to the owning team, determined from account structure or tags, through the channel it already uses: a team chat channel, the on-call tool or a ticketing queue. Each alert should include context: the scope, the amount, the change compared with normal, the services or resources that contributed and a link to investigate.

Tuning to avoid alert fatigue

Too many alerts cause alert fatigue: teams stop reading them and miss the important ones. Thresholds should combine an absolute and a relative condition, for example alerting when spend exceeds the expected amount by at least USD 500 and 20%, so that small services do not alert on trivial amounts and large services do not alert on normal variation. Each alert type should have a defined response, and alerts that consistently lead to no action should be tuned or removed.

Select all that apply

Avoiding alert fatigue

Exam skills 8.2.3

Identify ways to keep cost alerts useful.

Log in to try this activity Interactive activities are free with an account.

Responding to an anomaly

The following steps describe a typical response.

  1. Acknowledge

    The owning team acknowledges the alert within an agreed time.

  2. Investigate

    Identify the service, resource and change responsible, using cost and deployment data.

  3. Decide

    Classify the change as expected (such as a launch), a problem to fix or a false positive.

  4. Act

    Fix problems, for example by stopping a runaway job, and record expected changes.

  5. Learn

    Ask what guardrail or check would have prevented or caught it sooner.

Worked example

A runaway job

A data job misconfigured to retry endlessly costs USD 600 an hour from Friday evening. The team's monthly budget alert is set at 100% of USD 400,000. When will each control catch it?

The budget alert may not trigger for days or weeks, because USD 600 an hour adds about USD 14,400 a day to a large monthly budget; a forecast alert would trigger sooner but still not immediately. Anomaly detection on the team's account or the data service should flag the deviation within about a day. Routing the alert to the on-call engineer, rather than to a weekly email, could stop the job on Saturday instead of Monday, saving roughly USD 30,000.

Worked example

A sandbox budget

A company gives each engineer a sandbox account for experiments, with an expected limit of USD 300 a month. How should budgets be configured?

Create a budget of USD 300 per sandbox account with alerts to the engineer at 50% and 80% of actual spend and when forecast spend exceeds 100%. At 100% of actual spend, apply a budget action that attaches a policy preventing new resources, and notify the engineer. Because sandboxes hold no production workloads, stopping or restricting them is acceptable, and the action caps exposure without manual monitoring.

Check yourself

Why is a budget action that stops instances suitable for a sandbox account but rarely for production?

Show answer

Stopping sandbox resources only interrupts experiments, while stopping production resources would cause an outage for customers.

Exam Tips

Remember for the exam

  • Alert on forecast spend to act before a budget is exceeded.
  • Budget actions suit sandboxes and development accounts, rarely production.
  • Anomaly detection catches sudden spikes that budgets miss.
  • Route alerts to the owning team with context, and tune thresholds on absolute and relative change.