Skip to main content

Create billable metrics with Basic Filters

The Basic Filters editor is a structured query builder designed to provide out-of-the-box filters and aggregations on your usage stream. All metrics defined with the Basic Filters editor are created as streaming billable metrics.

Billable metrics can be created in both the Metronome app or using the Metronome API.

For this example, create a metric to track "API Calls" for a hypothetical cloud service.

  1. Navigate to the Billable Metrics section in Metronome.
  2. Click + Add new Billable Metric.
  3. Choose Basic filters.
  4. Name your metric (for example, API Calls).
  5. Select the event type (for example, api_request).
  6. Set filters:
    1. Property 1
      • property_name: "status"
      • operator: "In"
      • value: "success" (This ensures Metronome only counts successful API calls.)
    2. Property 2
      1. property_name: "user_id"
      • operator: "Exists"
      • (Metronome uses this as a group key to display API calls broken out by user.)
  7. Choose the aggregation method:
    • To count the number of API calls, not sum or average them, select "Count".
  8. Set a group key for user_id .
  9. Review and save your metric.

Billable metric creation flow

This billable metric counts all successful API calls broken out by user_id, providing a simple but effective measure of platform usage across an organization.

Prefer using the API? Here is an example request to set up the same metric:

curl -X POST https://api.metronome.com/v1/billable-metrics/create \ 
-H "Authorization: Bearer <TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"name":"API Calls",
"event_type_filter": {
"in_values": ["api_request"]
},
"property_filters": [
{
"name": "status",
"exists": true,
"in_values": ["success"]
},
{
"name": "user_id",
"exists": true
}
],
"aggregation_type": "COUNT",
"group_keys": [["user_id"]]
}'