Meters

Create meter

Create a meter.

post/v3/openmeter/meters

Request body

namestring required

Display name of the resource.

Between 1 and 256 characters.

descriptionstring

Optional description of the resource.

Maximum 1024 characters.

labelsLabels

Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

keystring required

A key is a unique string that is used to identify a resource.

aggregation'sum' | 'count' | 'unique_count' | 'avg' | 'min' | 'max' | 'latest' required

The aggregation type to use for the meter.

event_typestring required

The event type to include in the aggregation.

events_fromstring date-time

The date since the meter should include events. Useful to skip old events. If not specified, all historical events are included.

value_propertystring

JSONPath expression to extract the value from the ingested event's data property.

The ingested value for sum, avg, min, and max aggregations is a number or a string that can be parsed to a number.

For unique_count aggregation, the ingested value must be a string. For count aggregation the value_property is ignored.

dimensionsobject

Named JSONPath expressions to extract the group by values from the event data.

Keys must be unique and consist only alphanumeric and underscore characters.

Example request

{
  "labels": {
    "env": "test"
  },
  "key": "resource_key",
  "event_type": "prompt",
  "events_from": "2023-01-01T01:01:01.001Z",
  "value_property": "$.tokens",
  "dimensions": {
    "type": "$.type"
  }
}

Response

Meter created response.

idstring required

ULID (Universally Unique Lexicographically Sortable Identifier).

namestring required

Display name of the resource.

Between 1 and 256 characters.

descriptionstring

Optional description of the resource.

Maximum 1024 characters.

labelsLabels

Labels store metadata of an entity that can be used for filtering an entity list or for searching across entity types.

Keys must be of length 1-63 characters, and cannot start with "kong", "konnect", "mesh", "kic", or "_".

created_atstring date-time required

An ISO-8601 timestamp representation of entity creation date.

updated_atstring date-time required

An ISO-8601 timestamp representation of entity last update date.

deleted_atstring date-time

An ISO-8601 timestamp representation of entity deletion date.

keystring required

A key is a unique string that is used to identify a resource.

aggregation'sum' | 'count' | 'unique_count' | 'avg' | 'min' | 'max' | 'latest' required

The aggregation type to use for the meter.

event_typestring required

The event type to include in the aggregation.

events_fromstring date-time

The date since the meter should include events. Useful to skip old events. If not specified, all historical events are included.

value_propertystring

JSONPath expression to extract the value from the ingested event's data property.

The ingested value for sum, avg, min, and max aggregations is a number or a string that can be parsed to a number.

For unique_count aggregation, the ingested value must be a string. For count aggregation the value_property is ignored.

dimensionsobject

Named JSONPath expressions to extract the group by values from the event data.

Keys must be unique and consist only alphanumeric and underscore characters.

Example response

{
  "id": "01G65Z755AFWAKHE12NY0CQ9FH",
  "key": "tokens_total",
  "name": "Tokens Total",
  "description": "AI Token Usage",
  "aggregation": "sum",
  "event_type": "prompt",
  "value_property": "$.tokens",
  "dimensions": {
    "model": "$.model",
    "type": "$.type"
  },
  "created_at": "2024-01-01T01:01:01.001Z",
  "updated_at": "2024-01-01T01:01:01.001Z"
}

Changes

Changed in 2 of the 75 revisions of this API.3

    • the response property created_at became required for the status 201

      response-property-became-required

    • the response property updated_at became required for the status 201

      response-property-became-required

    This revision also has 1 change that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog

    • endpoint added

      endpoint-added

    This revision also has 6 changes that name no endpoint, such as unreferenced schemas being removed. See the revision's changelog