events
, which includes all of the raw usage events that are sent in to Metronome. Similar to the Basic Filters editor, billable metric SQL queries should include a set of filters that identify the correct usage events to query over, and an aggregation to turn these events into a value that Metronome will use as the quantity for downstream line items.
Metronome handles filtering down the SQL queries for individual customers over the course of their billing period. You do not need to include this logic in your queries - simply focus on filtering and aggregation!
events
tableevent_type
timestamp
properties.field_name
value
to use as the column for the metric quantity. If no column value
exists, Metronome uses the first column returned in the query. Any other columns returned can be used as group keys in downstream pricing and packaging.
COUNT
: Counts the number of rowsSUM
: Sums numbersMAX
: Takes the maximum of numbersMIN
: Takes the minimum of numbersAVG
: Averages numbersEARLIEST
: Returns the earliest value of a column based on its timestamp
LATEST
: Returns the latest value of a column based on its timestamp
COUNT DISTINCT
: Counts the distinct values in the expression+
, -
, *
, /
=
, !=
, >
, <
, ≥
, ≤
LEAST
: Returns the least of its argumentsGREATEST
: Returns the maximum of its argumentsROUND
: Rounds a number to a specified number of decimal placesCEIL
: Returns the smallest integer value that is greater or equal to the inputFLOOR
: Returns the largest integer value that is less than or equal to the inputAND
OR
NOT
CASE WHEN
IS NULL
IS NOT NULL
IN
NOT IN
=
!=
DATE_TRUNC
: Truncates the timestamp
field to the hour
or day
.CAST
+ Add new Billable Metric
.SQL query
.Storage latest daily max
).user_id
is returned so that it can be defined as a presentation_group_key
when creating a product from this metric. This allows you to display invoices broken out by user_id
. region
is returned so that it can be defined as a pricing_group_key
. This would allow you to add different rates for this billable metric for values of us-east-1
, us-west-1
, or ap-south-1
.invoice-breakdowns
endpoint, the costs will be incurred in the last time window of the billing period.