transaction_id
transaction_id
to ignore duplicate events. Once a usage event is accepted with a given transaction ID, subsequent events within the next 34 days with the same ID are treated as duplicates and ignored.
customer_id
customer_id
specifies which of your customers is responsible for any billing associated with the event. There are two ways to identify a Metronome customer in usage events: a customer ID or an ingest alias. Ingest aliases are useful when sending events using an identifier from your system, such as an email address or account number.
Each customer in Metronome may have multiple ingest aliases, and usage events with a customer_id
matching any of those aliases can be attributed towards that customer’s usage.
timestamp
timestamp
must be an RFC 3339 string with a 4-digit year, such as 2025-01-23T01:23:45Z
. When querying usage data or producing an invoice, this field is used to select only events that happened in a certain time range. Timestamps more than 24 hours in the future are rejected by the API.
event_type
event_type
works along with the properties
map to describe the details of the event. For example, a content delivery network (CDN) might generate events of the type http_request
with properties like domain
and bytes_sent
to support billing based on data transfer. They might also generate a different type of event, cache_invalidation
, with a property number_of_files
. You can name title the event_type
as needed, but for more insights check out how to design billable metrics.
properties
properties
map should be represented as strings, even though the values are often numeric. This prevents the loss of precision that often occurs in systems that use floating point numbers. Internally, Metronome uses arbitrary precision decimals to provide exact results of computation. Again, we advise sharing more data here than you might need initially so you can flexibly utilize this later on if need be.
/ingest
endpoint fails with a network error or a 5xx
HTTP status code, some of your events may have been ingested, but others may not. Always retry a failed call to /ingest
until you receive a 200
status code. The unique transaction_id
in each event prevents duplicate processing, so retries are always safe.
If your call to the Metronome /ingest
endpoint fails with a 429
HTTP status code, you have exceeded one of our rate limits. In this case, you should back off and retry the call after a delay. If the request continues to be rate-limited, wait for an exponentially increasing amount of time between retries.
/ingest
fails with a 4xx
HTTP
status code (besides 429
), this indicates an issue with the payload. Do
not automatically retry such a call. Instead, put the event aside in a dead
letter queue and trigger an
alarm so you can investigate the failure and resolve the issue.num_recipients
* size
), use SQL-based billable metrics.
transaction_id
for duplicate events to have the same ID. Metronome guarantees that only one event with a given transaction_id
is processed.
In the example of a per-node per-minute heartbeat, you might structure a transaction ID as follows:
unix_now()
is a function that returns the number of seconds since the Unix epoch. By including both the node ID and a minute-granularity timestamp in the transaction ID, it’s guaranteed that duplicate events from the same node in the same minute is ignored.
Using this type of transaction_id
means you also don’t have to worry about sending events too often. We recommend sending two or more heartbeats per measurement period. Duplicates are safely ignored, and by using this approach, you decrease the risk of missing a measurement period due to timer imprecision or a temporary delay.