Skip to content

Statistical cost anomalies (spikes and dips)

GET
/api/v1/anomalies
curl --request GET \
--url 'https://example.com/api/v1/anomalies?groupBy=service'

Flags spikes and dips in the daily cost series with a robust median/MAD detector computed at QUERY time — stateless, so retroactive FOCUS corrections are automatically re-scored. Uses the SAME groupBy dimensions as /api/v1/costs/daily and scores both the per-day TOTAL series (the sum over the day’s keys) and each grouping key’s own series. Flags are range-INDEPENDENT: the full stored history up to the requested end is scored, then only flags whose day falls inside [start, end] are returned, so a given day yields the identical flag regardless of the queried start. Passing currency scopes scoring to that billing currency. When currency is omitted, scoring defaults to the alphabetically-first billing currency in the requested window [start, end], falling back to full history when the window is empty. Every statistic is an exact decimal string and the detector’s fixed parameters are echoed, so each flag is hand-recomputable.

start
string format: date

Inclusive first calendar day (UTC) of the RETURNED flags; it does not affect the scoring baseline. Defaults to the full range of stored data.

end
string format: date

Inclusive last calendar day (UTC) to score and return. Defaults to the full range of stored data.

groupBy
string
default: service
Allowed values: service provider allocation

Cost grouping dimension (the same set as /api/v1/costs/daily).

currency
string
/^[A-Z]{3}$/

Optional three-letter uppercase billing currency whose history to score. Omit to use the alphabetically-first currency in the requested window [start, end], falling back to full history when the window is empty.

Detected anomalies for the requested period; [] when none.

Media typeapplication/json
object
currency
required

Billing currency of the scored costs (FOCUS BillingCurrency). Empty when no data matched.

string
parameters
required
object
k
required

Strict-threshold multiple of the scaled MAD, as a decimal string.

string
consistencyConstant
required

MAD-to-sigma consistency constant (R stats::mad), as a decimal string.

string
windowDays
required

Maximum trailing observed days in the baseline window.

integer
minObservations
required

Minimum baseline observations required to score a day.

integer
relativeFloor
required

Fraction of the absolute median a deviation must also reach, as a decimal string.

string
groupBy
required

The grouping dimension echoed verbatim from the request.

string
anomalies
required

Detected flags, ordered date-ascending, then total scope before key scope, then key-ascending. Never null; [] when nothing is flagged.

Array<object>
object
date
required

The UTC calendar day flagged.

string format: date
scope
required

“total” (the summed daily series) or “key” (one grouping key’s series).

string
key

The grouping key whose series flagged; present ONLY when scope is “key” (never for “total”, so a real key literally named “total” is unambiguous).

string
direction
required

“increase” when observed is above the median, “decrease” when below.

string
observed
required

The day’s observed value, as an exact decimal string.

string
median
required

Baseline median, as an exact decimal string.

string
mad
required

Baseline median absolute deviation, as an exact decimal string.

string
scaledMad
required

Mad times consistencyConstant, as an exact decimal string.

string
threshold
required

K times scaledMad — the strict flag threshold, as an exact decimal string.

string
deviation
required

The absolute difference of observed and median, as a decimal string.

string
Example
{
"currency": "USD",
"parameters": {
"k": "3",
"consistencyConstant": "1.4826",
"windowDays": 30,
"minObservations": 10,
"relativeFloor": "0.1",
"groupBy": "service"
},
"anomalies": [
{
"date": "2026-06-18",
"scope": "total",
"key": "Amazon Elastic Compute Cloud",
"direction": "increase",
"observed": "31.2",
"median": "4.6809",
"mad": "0.0013",
"scaledMad": "0.00192738",
"threshold": "0.00578214",
"deviation": "26.5191"
}
]
}

Invalid start date, end date, groupBy value, or currency shape; or groupBy=allocation was requested but no allocation rules are configured or the rules file was not found.

Media typetext/plain
string

The cost query failed, including an unreadable, malformed, or invalid allocation rules file.

Media typetext/plain
string