Meters are there to filter and aggregate the events that are ingested. Said another way, this is how you define what usage you want to charge for, based on the events you send to Polar. For example:

  • AI usage meter, which filters the events with the name ai_usage and sums the total_tokens field.
  • Video streaming meter, which filters the events with the name video_streamed and sums the duration field.
  • File upload meter, which filters the events with the name file_uploaded and sums the size field.

You can create and manage your meters from the dashboard. Polar is then able to compute the usage over time, both globally and per customer.

Creating a Meter

To create a meter, navigate to the Meters page in the sidebar and click the “Create Meter” button.

Filters

A filter is a set of clauses that are combined using conjunctions. They’re used to filter events that you’ve ingested into Polar.

Clauses

A clause is a condition that an event must meet to be included in the meter.

Property

Properties are the properties of the event that you want to filter on.

If you want to match on a metadata field, you can use the metadata key directly. No need to include a metadata. prefix.

Operator

Operators are the operators that you want to use to filter the events.

  • Equals
  • Not equals
  • Greater Than
  • Greater Than or Equals
  • Less Than
  • Less Than or Equals
  • Contains
  • Does Not Contain

Value

Values are automatically parsed in the filter builder. They’re parsed in the following order:

  1. Number — Tries to parse the value as number
  2. Boolean — Checks if value is “true” or “false”
  3. String — Treats value as string as fallback

Conjunctions

A conjunction is a logical operator that combines two or more clauses.

  • and — All clauses must be true for the event to be included.
  • or — At least one clause must be true for the event to be included.

Aggregation

The aggregation is the function that is used to aggregate the events that match the filter.

For example, if you want to count the number of events that match the filter, you can use the Count aggregation. If you want to sum the value of a metadata field, you can use the Sum aggregation.

  • Count — Counts the number of events that match the filter.
  • Sum — Sums the value of a property.
  • Average — Computes the average value of a property.
  • Minimum — Computes the minimum value of a property.
  • Maximum — Computes the maximum value of a property.

If you want to use a metadata property in the aggregation, you can use the metadata property directly. No need to include a metadata. prefix.

Example

The following Meter Filter & Aggregation will match events that have the name openai-usage and sum units over metadata property completionTokens.

You can Preview the events matched by the meter while creating it.

Good to know

A few things to keep in mind when creating and managing meters:

Updating a Meter

You may update a meter’s filters or aggregation function as long as the meter doesn’t have any processed events.

Deleting a Meter

Meters are permanent. Once created, they cannot be deleted.

Was this page helpful?