The OpenMeter provides a robust and flexible way to define and manage meters. This configuration is designed to offer multiple aggregation methods and window sizes, making it highly adaptable to your specific needs.
Meters in OpenMeter are defined in the meters section of the configuration file.
Each meter comprises the following attributes:
slug: A unique identifier for the meter. This is used to reference the meter in the OpenMeter API.
description: A human-readable description of the meter.
eventType: The event type that the meter is tracking. This is used to filter the events that are used to calculate the meter.
valueProperty: The JSON path to the property that contains the value to be metered. This is optional when the aggregation is
aggregation: The aggregation type to use for the meter. See Aggregation Types for more information.
groupBy: A map of JSON paths to group the metered data by. This is optional.
windowSize: The size of the time window to use for the meter. This is optional and defaults to
Counting API requests per method and path:
meters: - slug: api_request_count description: Counts the number of API requests eventType: api_request aggregation: COUNT groupBy: method: $.method path: $.path
Summing up the total tokens used in OpenAI calls per model:
meters: - slug: openai_token_usage description: Total tokens used in OpenAI calls eventType: openai valueProperty: $.total_tokens aggregation: SUM groupBy: model: $.model
OpenMeter allows various types of aggregations, making it suitable for a wide range of applications.
The SUM aggregation type calculates the total sum of the metered values for a specific time window. This is useful for accumulating metrics like total API calls made, total data transferred, LLM tokens used or total time spent on a service.
COUNT aggregation type counts the number of events that occur within a specific time window.
This is often used for metrics that are inherently countable, such as the the number of transactions processed.
COUNT aggregation type does not require a
valueProperty to be defined.
The AVG (Average) aggregation type calculates the mean value of the metered data points within a specific time window. This is useful for metrics where you want to understand the average behavior over time, such as average CPU usage or average transaction value.
The MIN aggregation type identifies the minimum value among the metered data points within a specific time window. This is useful for metrics where the lowest value is of interest, such as minimum available storage or minimum response time.
MAX aggregation type identifies the maximum value among the metered data points within a specific time window.
This is useful for metrics where the highest value is of interest, such as maximum load on a server or maximum transaction value.