> ## Documentation Index
> Fetch the complete documentation index at: https://alguna.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Metrics

> Define billable metrics so you can meter usage

Alguna supports various billable metrics in order to meter usage. These metrics describe
how to aggregate a set of billable events over a period of time.

<Steps>
  <Step title="Billable Metric Details">
    Start by defining the **Billable Metric** that will track and aggregate customer usage for billing purposes.

    * **Metric Name**: Provide a clear, concise name for your metric (e.g., "API Requests").

    * **Description**: Describe what the metric measures (e.g., "Tracks the number of API requests made by the customer").
  </Step>

  <Step title="Choose Events">
    Next, select the event or events that will contribute to your billable metric. Events represent individual customer actions or transactions that should be aggregated for billing.

    * **Event Name**: Start typing to either create a new event or select an existing event from the dropdown.
  </Step>

  <Step title="Filter by Property (Optional)">
    Optionally, you can apply filters to further refine your metric by selecting specific event properties. This helps narrow down which events should be counted toward the billable metric.

    * **Property Name**: Choose the property name you want to filter by (e.g., "region").

    * **Condition**: Select a condition such as `equals to`, `contains`, or `does not contain`.

    * **Property Value**: Specify the property value that should be matched (e.g., "US").
  </Step>

  <Step title="Aggregation Method">
    Choose how the events should be aggregated to calculate the final value for your billable metric.

    * **Aggregation Type**: Select how you want to calculate the metric, such as:

      * `count`: The number of events that match the metric.

      * `sum`: The sum of the values of the specified field.

      * `average`: The average of the values of the specified field.

      * `min`: The minimum value of the specified field.

      * `max`: The maximum value of the specified field.

    * **Over Property**: Specify the event property that will be used for aggregation (e.g., "value" or "duration").

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/alguna-20/billable-metrics/images/billable-metrics/billable-metric.png" />
    </Frame>
  </Step>
</Steps>

## Example

Let's say you have a SaaS application that has mixed pricing based on the number of seats and API requests used. You are a global
company and therefore you have APIs deployed in NA, EMEA and APAC, and a customer is charged differently based on which region
they are using.

In this case you would want to send two types of events:

* `merchant_seat_changed`: This event would be sent when a new user is added or removed from the merchant's account. This event
  would have a `total_seats` property that would be the total number of users on the account.

* `api_request`: This event would be sent when a customer makes an API request. This event would have a `region` property that
  would be the region that the API request was made to, and a `value` that describes the number of requests used.

And create metrics:

* **Merchant Seats**: You may want to aggregate by `average` or `max` depending on how you want to charge your customers.

* **API Requests (NA)**: Filtered by `region` = `NA` and aggregated by `sum`.

* **API Requests (EMEA)**: Filtered by `region` = `EMEA` and aggregated by `sum`.

* **API Requests (APAC)**: Filtered by `region` = `APAC` and aggregated by `sum`.

## Ingesting Events

See the [Meter Usage](/billable-metrics/send-usage) page for more information on how to ingest events.
