Rule
What is a Rule?
The rule specifies what conditions should trigger an event. Given that OpenMeter can handle millions of ingested events per day, it is not a good practice to send notifications to the customer's backend system at this rate.
Rules solve this issue by allowing our customers to specify the events they are interested in.
Example
Let's say we have a feature called llm_tokens
that measures token usage for
our large language models.
Each end user is allowed to use 10,000 of those tokens per month. They have a metered entitlement with this hard limit.
Our backend needs to be notified when users reach 80% of their quota so that we can send them a notification email to buy more tokens.
In this example, the backend is not interested in always getting an updated balance; it would just need to be notified when it reaches the 80% mark. By defining a Rule with an 80% threshold, we achieve this behavior.
Rule types
Each rule has a type
to support multiple event types. For now, OpenMeter only
supports the entitlements.balance.threshold
, which allows the end users to get
notified about Entitlement Balance
changes.
Type | ||
---|---|---|
Entitlement Balance Threshold | entitlements.balance.threshold | Sends a notification a specified usage threshold has been reached on an entitlement |
Entitlement Reset | entitlements.reset | Sends a notification if an entitlement has been reset either manually or automatically |
Invoice Created | invoice.created | Sends a notification on invoice creation |
Invoice Updated | invoice.updated | Sends a notification when an invoice changes state |