{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/Meter",
  "title": "Meter",
  "description": "A meter is a configuration that defines how to match and aggregate events.",
  "type": "object",
  "properties": {
    "id": {
      "description": "ULID (Universally Unique Lexicographically Sortable Identifier).",
      "type": "string",
      "example": "01G65Z755AFWAKHE12NY0CQ9FH",
      "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$",
      "readOnly": true,
      "title": "ULID"
    },
    "name": {
      "description": "Display name of the resource.\n\nBetween 1 and 256 characters.",
      "type": "string",
      "maxLength": 256,
      "minLength": 1
    },
    "description": {
      "description": "Optional description of the resource.\n\nMaximum 1024 characters.",
      "type": "string",
      "maxLength": 1024
    },
    "labels": {
      "$ref": "#/components/schemas/Labels"
    },
    "created_at": {
      "description": "An ISO-8601 timestamp representation of entity creation date.",
      "type": "string",
      "format": "date-time",
      "example": "2023-01-01T01:01:01.001Z",
      "readOnly": true,
      "title": "RFC3339 Date-Time"
    },
    "updated_at": {
      "description": "An ISO-8601 timestamp representation of entity last update date.",
      "type": "string",
      "format": "date-time",
      "example": "2023-01-01T01:01:01.001Z",
      "readOnly": true,
      "title": "RFC3339 Date-Time"
    },
    "deleted_at": {
      "description": "An ISO-8601 timestamp representation of entity deletion date.",
      "type": "string",
      "format": "date-time",
      "example": "2023-01-01T01:01:01.001Z",
      "readOnly": true,
      "title": "RFC3339 Date-Time"
    },
    "key": {
      "$ref": "#/components/schemas/ResourceKey"
    },
    "aggregation": {
      "description": "The aggregation type to use for the meter.",
      "type": "string",
      "enum": [
        "sum",
        "count",
        "unique_count",
        "avg",
        "min",
        "max",
        "latest"
      ],
      "x-speakeasy-unknown-values": "allow"
    },
    "event_type": {
      "description": "The event type to include in the aggregation.",
      "type": "string",
      "example": "prompt",
      "minLength": 1
    },
    "events_from": {
      "description": "The date since the meter should include events.\nUseful to skip old events.\nIf not specified, all historical events are included.",
      "type": "string",
      "format": "date-time",
      "example": "2023-01-01T01:01:01.001Z",
      "title": "RFC3339 Date-Time"
    },
    "value_property": {
      "description": "JSONPath expression to extract the value from the ingested event's data property.\n\nThe ingested value for sum, avg, min, and max aggregations is a number or a string that can be parsed to a number.\n\nFor unique_count aggregation, the ingested value must be a string. For count aggregation the value_property is ignored.",
      "type": "string",
      "example": "$.tokens",
      "minLength": 1
    },
    "dimensions": {
      "description": "Named JSONPath expressions to extract the group by values from the event data.\n\nKeys must be unique and consist only alphanumeric and underscore characters.",
      "type": "object",
      "example": {
        "type": "$.type"
      },
      "additionalProperties": {
        "type": "string"
      }
    }
  },
  "example": {
    "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"
  },
  "required": [
    "id",
    "name",
    "created_at",
    "updated_at",
    "key",
    "aggregation",
    "event_type"
  ]
}