usage-events

Get the monthly spend forecast

Changed on

Returns the organization's recorded and predicted spend, in US dollars, for each day of the current calendar month in time_zone. For a caller whose access covers only particular principals or groups, the operation reads only the events of those principals and groups. The prediction trains on up to 28 completed days, and the day in progress never counts. Each series covers at most one calendar month, so the response isn't paginated.

Predictions are statistical estimates. They don't check or enforce any budget.

get/v1/ai-cost-management/events/forecast

Request

  • Base URL
    https://global.api.konghq.com
  • Auth
    • HTTP bearer
    • or HTTP bearer
    • or HTTP bearer
    • or HTTP bearer

Query parameters

method, 'auto' | 'weekly_seasonal' | 'linear_regression' | 'exponential_smoothing'

The prediction method:

  • auto: weekly_seasonal once 14 completed training days exist, and exponential_smoothing before that.
  • weekly_seasonal: the mean daily spend for each weekday. Needs 14 completed training days.
  • linear_regression: a straight-line fit of daily spend, extended to the end of the month. Needs 2 completed training days.
  • exponential_smoothing: a weighted average of recent daily spend, carried forward. Needs 2 completed training days.

A method named in the request never falls back to another when the history is too short. The response's status is then insufficient_history. Defaults to auto.

time_zone, string iana-time-zone

The IANA time zone whose calendar sets the month and its days.

The name must be spelled as the time zone database spells it, such as Europe/Budapest, not europe/budapest. Offsets such as +02:00 aren't accepted. Defaults to UTC.

Response

The month's recorded daily spend and the forecast for the rest of the month.

object required
period, object required

The calendar month the forecast covers: the current month in time_zone.

observed_at, string date-time required

The end of the observed history, as an RFC 3339 timestamp in UTC. It's the start of the day in progress in time_zone, so actual and the training history cover only the completed days before it.

generated_at, string date-time required

When the service computed the forecast, as an RFC 3339 timestamp in UTC.

method, 'weekly_seasonal' | 'linear_regression' | 'exponential_smoothing' required

The method the service used. For a request with auto, it's the method that auto chose, so it's never auto.

status, 'ready' | 'insufficient_history' required

Whether the forecast has predictions. It's ready when predicted holds them. It's insufficient_history when method has fewer completed training days than it needs, and predicted is then empty.

training, object required

The completed days whose spend trains the prediction, at most the last 28. Days before the organization's first event since the start of the previous month don't count, and later days without events count as zero spend.

actual, object[] required

The recorded spend for each completed day of the month, oldest first.

predicted, object[] required

The predicted spend for each remaining day of the month, from the day of observed_at through the last day, oldest first. Empty when status is insufficient_history.

Changes