Create and manage alerts
Metronome alerts provide for comprehensive monitoring of your customers and billing. Alerts cover a variety of use cases for managing product access, such as gating customer spend, setting usage thresholds, and monitoring commitment drawdowns. You can establish alerts for individual customers or across all customers.
Create an alert
You can create alerts through the Metronome app or the /alerts/create endpoint.
Note that Metronome uses webhook notifications to notify you of alert status changes. You must create a webhook endpoint on your server to handle these events.
This example creates an alert for when a customer's credit balance reaches $5 remaining, with a low credit balance alert for all customers with an initial sign-up credit.
Your customers may want the ability to enable their own notifications (for example, when their balance is low). You can build that functionality into your product, and then call the Metronome /alerts/create endpoint accordingly.
Alert types
Metronome offers many alert types. These generally fall into two categories: Commitment/Credit alerts and Spend alerts. Each alert type is measured either once per day or in real time as usage is sent to Metronome.
Every alert type goes into an in_alarm
state when the threshold is met. (See also the alert triggers for details of the alert evaluation process.)
Commitment and credit alerts
This category of alerts evaluates commitments or credits separately, except for the Low credit and commitment balance alert, which alerts on the sum of both.
Low remaining days in credit/Low remaining days in commitment
This alert type sets a threshold for the number of days remaining on a particular credit grant or commitment. If multiple sets of credits or commits exist for a customer, the alert evaluates each of them independently and sends separate notifications as each credit or commit reaches the threshold. This alert type is measured once a day.
Low credit balance reached/Low commitment balance reached
This alert type sets a threshold for a specific credit type. The alert labels a customer as in_alarm
if the customer's credit or commit balance for the credit type reaches or goes below your set threshold. If multiple credits or commits exist for a customer, the alert sums up the remaining balances across all credits or commitments to compare against the threshold. This alert type is measured in real time as usage is sent to Metronome.
Low remaining credit percentage/Low remaining commitment percentage
This alert type sets a percentage threshold for a specific credit type. The alert labels a customer as in_alarm
if the percentage of available credits on all active credit grants or commits for that credit type reaches or goes below your set threshold. This alert type is measured in real time as usage is sent to Metronome.
The low remaining percentage alert only takes into account active credit grants or commits. The alert calculation automatically excludes expired credits. Low credit balance alerts by default apply to the total credit balance on a customer.
To alert on a specific credit grant or commit, set a custom field on the object in Metronome and use advanced filters to alert only on commits with that specific custom field value.
Low credit and commitment balance reached
This alert type sets a threshold on the remaining balance across a customer’s set of prepaid commitments, postpaid commitments, and credits. If multiple credits and commitments exist for a customer, the alert sums up the remaining balances across all credits and commitments to compare against the threshold. This alert type is measured in real time as usage is sent in to Metronome.
Spend alerts
Spend threshold reached
This alert type sets a threshold for a specific credit type. The alert labels a customer as in_alarm
if the customer's usage-based spend prior to commit and credit drawdown for their current billing period reaches or goes above your set threshold. This alert evaluates against the sum of all usage-based charges for a particular customer, including usage drawdowns on credits and commits. This alert type is measured throughout the day.
Credit and commit purchases are not factored into a customer's spend threshold alert. For example, if the threshold is set at $10,000, an actual billing spend of $7,000 plus a credit purchase of $3,000 does not trigger the alert.
Spend alerts are evaluated only against direct spend in a specific credit type. A spend alert threshold configured for a currency always evaluates to ok
if you are using a custom pricing unit for a customer's line items.
To avoid this, configure spend alert thresholds to use the same pricing unit as the line items on a customer's invoice.
Invoice total reached
This alert type sets a threshold for an invoice total and sends a notification if any of the customer's active invoices reaches or exceeds the configured threshold. Note that the invoice total used is the net total after any credits, commits, or other adjustments have been applied. The alert evaluates each active invoice separately. This alert type is measured in real time as usage is sent in to Metronome.
There are two filtering criteria for this alert type:
- Currency (required), only invoices in the specified currency are evaluated.
- Invoice type (optional), only invoices of the specified type are evaluated. Example invoice types include usage invoices, scheduled invoices, and credit purchase invoices. If unspecified, all invoice types are evaluated.
Alert states
As the data relevant to alerts is evaluated, the alert state may be updated. The three alert states are:
-
evaluating
The state for an alert that has yet to be evaluated, typically due to a customer having just been created. To avoid race conditions, Metronome does not evaluate an alert within the first two minutes of customer creation.
-
ok
The state for an alert that has been evaluated but the customer is below the alert threshold. For example, a $200 spend threshold alert is considered in
OK
state for a customer with only $100 of spend. -
in_alarm
The state for an alert that has been evaluated and the customer has breached the alert threshold. For example, a $200 spend threshold alert is considered
in_alarm
as soon as the customer spends $200 or more.
Despite potential lag in the pipelines, usage alerts and invoice generation pull from the same usage aggregation source. Invoices and alerts should always reflect the same customer state.
Access alert information
You can view all of your alerts and their statuses in the Metronome app. To view a specific customer's alerts, select the customer and then click on the Alerts tab.
Through the API, you can retrieve a customer's alert status and alert information for a specific alert using the/customer-alerts/get endpoint. Retrieve every alert using the /customer-alerts/list endpoint.
Archive an alert
You can archive an alert through the Metronome app or the API using the /alerts/archive endpoint.
To update an alert—for example, to change the threshold—first archive it (using the Metronome app or API), then re-create it with the updated value.
Alert triggers
To assess whether or not an alert notification should be sent, Metronome routinely evaluates customers with associated alerts. If a customer's watched value—credit balance, spend, and so on—hits a threshold, an alert notification is sent.
There are three possible triggers for an evaluation:
-
Usage events are ingested
-
Customer metadata changes (for example, a plan is assigned or a new ingest alias is assigned)
Specifically, any CRUD (create, retrieve, update, and delete) action impacting alerts, customers, customer ingest aliases, contract, commitments, and credit grants are considered metadata changes and trigger an alert evaluation.
-
Time passes
Alerts triggered by time-based state transitions (for example, a new billing period starts or ends or a credit grant starts or expires) are evaluated at 00:00UTC on the specified date of transition. Daily alert types (such as low remaining days in a commitment or low remaining credit percentage and usage threshold) are evaluated at 04:00UTC every day.
Spend threshold and credit threshold alerts have notifications sent within minutes of that condition being met. Daily alerts are evaluated at 04:00UTC and sent out shortly thereafter with a 24-hour SLA.
Forcing alert re-evaluation
Alerts are continuously evaluated, but Metronome only triggers notifications when an alert changes state. This could lead to unintended behavior if your systems reset their state in response to changes in a customer's plan and are expecting an alerts re-notification.
In those situations you can force a re-evaluation of an alert for a customer through the /customer-alerts/reset endpoint. This puts the alert into the ok
state for that customer and enqueue it to be re-evaluated as if customer metadata had changed.
Webhook notifications
When a customer's alert status transitions to in_alarm
, Metronome sends a webhook notification. See the webhooks documentation for requirements and best practices in setting up your webhook endpoint.
Talk to your Metronome representative if you'd like to also receive webhook notifications when an alert is resolved.
Metronome maintains an internal system for alert notification failures. You may be contacted directly if your webhook fails to acknowledge notifications. However, should you have concerns about alert functionality:
- Review the alert state via the API
- If you see that the alert is
in_alarm
and you do not receive a notification, review the associated webhook endpoint configuration, and test a customer in sandbox to validate the notification process with another alert - If you see that the alert is
ok
but you suspect that it should be in alarm, review the customer profile in the Metronome app for any recent changes (e.g., a new credit grant purchase)
Metronome alerts send notifications as soon as the system transitions them to the in_alarm
state. However, there are some instances in which some time may pass between a change of state in Metronome and the notification being sent:
- Metronome does not evaluate for the first two minutes after customer creation to avoid race conditions
- In rare cases, lag may be introduced due to a delay in the events pipeline or a spike in activity leading to a large alert evaluation or notification queue
The below shows example webhook payloads for each alert type.
- Commitment balance
- Commitment percentage
- Days in commitment remaining
- Credit balance
- Credit percentage
{
"id": "3dbaab98-45e9-4b55-864c-4650497d80d7",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "445b849e-1366-4580-a6cc-f488e27c059f",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 20000,
"alert_name": "Commit balance low",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"remaining_balance": 5000,
"triggered_by": "usage"
},
"type": "alerts.low_remaining_commit_balance_reached"
}
{
"id": "a46e6535-bf4d-4a8f-9299-f52b04fa6b14",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "50055d7e-ac17-4c4d-9e40-b81ae8da5acc",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 5000,
"alert_name": "Commit percentage",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"remaining_percentage": 25,
"triggered_by": "usage"
},
"type": "alerts.low_remaining_commit_percentage_reached"
}
{
"id": "0cbf5e09-605f-4edf-9009-bd6959cd908b",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "829f4b7b-cc07-48f8-afae-61160088a0e1",
"commit_id": "76e6ec3e-ae4a-4a7d-9980-9a2fe806905b",
"threshold": 5,
"alert_name": "Days in commitment",
"remaining_days": 5
},
"type": "alerts.low_remaining_days_for_commit_segment_reached"
}
{
"id": "1e936aba-cb64-4434-bcff-1236fa0240f1",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "c5e25700-941c-460a-b6dd-6240c3f62ec8",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 10000,
"alert_name": "Contract credit balance",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"remaining_balance": 10000,
"triggered_by": "usage"
},
"type": "alerts.low_remaining_contract_credit_balance_reached"
}
{
"id": "0592dd33-8f1f-4e4a-a7d7-e09606ee3c2d",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "87d1211c-dff5-4a2c-ad25-2e2784f7d572",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 80,
"alert_name": "Contract credit percentage",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"remaining_percentage": 50,
"triggered_by": "usage"
},
"type": "alerts.low_remaining_contract_credit_percentage_reached"
}
- Days in credit remaining
- Contract credit and commit balance
- Spend threshold
- Monthly spend
- Invoice total
{
"id": "6500fedc-6914-4e44-8f64-f4e9edeaa23f",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "f1af58df-c6be-4ddf-a0f0-49d366247002",
"credit_id": "ad178b76-334f-43a2-87aa-3a951fd939d4",
"threshold": 5,
"alert_name": "Days in contract credit",
"remaining_days": 5
},
"type": "alerts.low_remaining_days_for_contract_credit_segment_reached"
}
{
"id": "8d9cebd2-9c57-4a35-a468-bd73fa2ffa89",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "618a4ca8-c8d9-4822-addc-bd3008eb8428",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 20000,
"alert_name": "Balance low",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"remaining_balance": 5000,
"triggered_by": "usage"
},
"type": "alerts.low_remaining_contract_credit_and_commit_balance_reached"
}
{
"id": "ba0022aa-f4ba-4d33-b88b-b50cb4fd8f62",
"properties": {
"customer_id": "6f04d9b5-186c-4698-89de-30b57ec614b4",
"alert_id": "6b881dcc-5354-49c5-94e1-c821ad2228f7",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 10000,
"alert_name": "Spend",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"triggered_by": "usage"
},
"type": "alerts.spend_threshold_reached"
}
{
"id": "9e192496-d7c2-4e45-9f31-79c5240e06e6",
"properties": {
"customer_id": "ac39ecc3-87ee-4d58-8ec0-24041464a5dd",
"alert_id": "48389aea-d739-4420-8570-3223b5bba587",
"timestamp": "2024-10-07T15:08:44.865Z",
"threshold": 10000,
"alert_name": "Monthly spend",
"credit_type_id": "2714e483-4ff1-48e4-9e25-ac732e8f24f2",
"triggered_by": "usage"
},
"type": "alerts.monthly_invoice_total_spend_threshold_reached"
}
{
"id": "a1ea9901-46e3-4888-acf1-4d9adaec4cdf",
"properties": {
"customer_id": "59071db8-0502-4255-b1ac-dfebf5d9e1e9",
"alert_id": "2c1bf7d7-d981-4591-9f45-d0c95789c5e3",
"timestamp": "2024-06-05T00:41:19.860839Z",
"threshold": 1000,
"alert_name": "Invoice total",
"invoice_id": "6644b5ec-394a-4d07-a037-e2827a0af4be",
"invoice_total": 1600,
"triggered_by": "usage"
},
"type": "alerts.invoice_total_reached"
}