Skip to content

How cost anomaly detection works, and what to do once one fires

The CostReveal team, , 7 minute read

Most cost anomaly alerts fail in one of two ways. Either they fire so often that everyone mutes them, or they fire once, in a channel nobody owns, and the spike is still on the next bill. Detection is the easy half. The hard half is an alert that is right, says what drove it, and reaches someone who will act on it. This post explains how cost anomalies are found in billed spend, and what turns an alert into work that gets done.

What counts as an anomaly

An anomaly is a day spend fell outside its normal range. Defining "normal" is where most detection goes wrong:

  • Against the right baseline. Spend has a weekly rhythm: weekdays differ from weekends, and Mondays from Fridays. CostReveal compares each day with the same weekday over the four weeks before, using the median, so one unusual Tuesday does not move what the next Tuesday is expected to be.
  • With a range that does not drift. The normal range is three robust deviations either side of the expected figure. A robust measure is not widened by a past spike, so a service that spiked once is not then allowed to spike again unnoticed.
  • Large enough to matter. A service's move must be at least 1 percent of the project's average daily spend, so a service moving by cents never counts, and every move at least a tenth of what was expected, so steady growth of a few percent a day never counts either.

Both rises and drops are listed. A drop can matter as much as a rise: a service that stopped billing may be a service that stopped working.

Where spend is owned, and below the service

A service as a whole is only one place a spike can be. A large service's normal range can hide a spike in one of its parts, and a team's spike can sit inside services that look normal. So the same method runs through four lenses:

  • Services, each provider's service as a whole.
  • Usage types, each one within its service, such as an EC2 instance type or a model's output tokens. One found on a day its service stayed in range is marked hidden in its service: the spike a service-level check misses.
  • Teams and owners, each team, feature and value of the project's own dimensions, as spend is attributed to them, held to a move of 1 percent of their own daily spend and a tenth of 1 percent of the project's, so a large team's routine move and a small team's cents both stay quiet. Customers and users are watched where someone asks for one.
  • Saved views, each view that filters spend, as a budget on the view reads it.

Read from the bill, not a guess

Anomalies are found in billed spend, the figures the provider invoices, through each provider's last complete day. That has a cost and a benefit. The cost is timing: a spike is found once the day is billed, not the minute it starts. The benefit is that every anomaly is real money on a real bill, never an estimate that later disappears.

The detection also respects how each provider bills. A month billed as one charge, as Datadog bills a month it has closed, or the weekends of a service that runs on weekdays only, is never read as days of nothing that would make every other day look out of range.

An alert that explains itself

An anomaly that only says "EC2 rose 40 percent" starts an investigation. One that says who it was for ends one. For each anomaly, What drove it divides the day's move by every dimension: team, account, region, model, feature, customer and each custom dimension, with the values that moved most and the rest together. The figures add up to the move exactly.

What moved then goes below the service, from the bill itself, for a team or a saved view its own share of each line across its services: the usage types and resources that moved most, such as a Lambda function's GB-seconds or one EC2 instance, and how much of each move was more use and how much a higher price, with resources new on the day or gone from it set apart. Where a business metric sent for the whole project, such as orders, moved with the spend at the same cost per unit, the anomaly is called growth, so a busy day for the business does not read as waste.

What changed sets beside it the changes made around it, on the day and the day before, from each cloud's own records: CloudTrail's management events in each AWS account, each Azure subscription's Activity Log, each Google Cloud project's Admin Activity audit logs, and each Kubernetes rollout or autoscaler change the cluster's Collector sends. A change to a resource that moved is listed first, with who made it, and one to the resource that moved most is marked as such; the rest are those made where the spend moved. Where an account's changes cannot be read, the anomaly says so and what access to add. The alert states what changed too, read before it is sent.

Separately, cost spike alerts go out when a day rises well above the seven before it, by a percentage each project sets, and name in the alert itself the team, account or workload whose spend rose most, and what moved below the service.

From alert to done

Finding anomalies is only useful if someone works through them. In Insights, every anomaly has a status, someone it is given to, and comments:

  • New: no one has looked at it yet.
  • In progress: someone is working on it.
  • On hold: waiting on something, such as a planned change.
  • Done: acted on.
  • Dismissed: looked at, and nothing to do, such as a spike from a planned migration.

Each anomaly also reaches the people it belongs to. Anyone who sees the whole project can watch a team, a feature or a saved view, and each of its anomalies is emailed to them as it is found, with what drove it and what moved. A person limited to their own part of a project watches that part from the start, and reads only its figures. Recipients and webhooks choose anomalies as a kind of alert, and a saved view can send its own to a Teams channel, PagerDuty or any system that reads signed JSON.

Give an anomaly to anyone who can see the project, and they are emailed a link, and again when someone else comments. Each change records who made it and when, in the item and in the audit log. Home counts the open ones given to each person, so nothing given to you waits unseen.

This is what turns a noisy channel into a queue with owners. A dismissed spike with a comment saying "planned migration" is a decision someone can find again next quarter, not a forgotten message.

Tuning without muting

The reason teams mute alerts is that they cannot trust them. A baseline by weekday, a range a past spike cannot widen, and thresholds that ignore cents and steady growth remove the most common false alarms. What is left is worth a person's attention, and the drivers tell that person where to look.

What it does not claim

Detection runs on billed spend through each provider's last complete day, so it does not catch a spike within the hour it starts. What moved reaches as far as each bill states: a resource where the provider names one, and use and price where it states a quantity. An anomaly says a day was outside its normal range, and the drivers say what moved, measured. What changed is evidence set beside it, matched by rules to the resources and places that moved, never stated as the cause; whether that was a launch, a leak or a planned load test is for the owner to say, and their comment records it.

Frequently asked questions

How is an anomaly detected? A day's billed spend for a service, a usage type, a team or owner, or a saved view is compared with the median of the same weekday over the four weeks before, and counts when it is outside three robust deviations and large enough to matter.

Can a spike hide inside a service? Yes, and it is found: each usage type is watched within its service, and one that left its range on a day its service did not is marked hidden in its service.

Does each team hear of its own anomalies? Yes. A team, feature or saved view can be watched, and a person limited to their own part of a project is emailed its anomalies with only its figures.

Why does steady growth not raise alerts? A move must be at least a tenth of what was expected, and steady growth of a few percent a day is less than that.

Are drops reported too? Yes. A service that stopped billing is listed, as it may have stopped working.

How fast is an anomaly found? Once the provider has billed the day, through its last complete day.

Does it say which resource moved? Yes, where the bill names one: What moved lists the usage types and resources that moved most, each divided into more use and a higher price.

Does it say what changed? Yes, where each cloud's records can be read: the changes made on the day and the day before, those to a resource that moved first, with who made each. Matched by rules, never guessed.

How does a team work through anomalies? Each has a status, someone it is given to, and comments, with every change recorded in the audit log.

Keep reading