2 years 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_propertyordered bytime_based_property.LATEST_BY(value_property, time_based_property): Returns the latest value ofvalue_propertyordered bytime_based_property.
For example, you might use these functions to compute the earliest and latest storage_gbvalues 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.