a year ago
New custom SQL functions
Orb's billable metrics layer now supports two time-based SQL functions, EARLIEST_BY
and LATEST_BY
. These can be used in combination with the timestamp of an event to perform queries that take the latest or earliest event in a billing period. They behave as follows:
EARLIEST_BY(value_property, time_based_property)
: Returns the earliest value ofvalue_property
ordered bytime_based_property
.LATEST_BY(value_property, time_based_property)
: Returns the latest value ofvalue_property
ordered bytime_based_property
.
For example, you might use these functions to compute the earliest and latest storage_gb
values seen during the month to naively compute storage added.
Note that Orb automatically applies time range filtering to billable metric queries based on the billing period bounds.