---
title: "Query Metrics"
url: "https://nov18-dev.movespot.fyi/apis/konnect-metrics-endpoint-4/versions/067cb7dd-3237-4170-bfaf-95928b927e78/operations/metrics"
---

> Full API specification: https://nov18-dev.movespot.fyi/apis/konnect-metrics-endpoint-4/versions/067cb7dd-3237-4170-bfaf-95928b927e78.md

# Query Metrics

`POST` `/metrics`

Operation ID: `metrics`

Post a query to the endpoint to retrieve aggregated metrics down to the minute. Data can be requested to group by any 2 dimensions, and any number of filter conditions.

## Request body (required)

Content types: `application/json`

## Responses

- `200` - Aggregated results of the query
- `400` - Bad Request
- `401` - Unauthorized
- `403` - Forbidden

## OpenAPI definition

```yaml
openapi: 3.0.2
info:
  title: Konnect Metrics Endpoint
  version: 4.0.0
servers:
  - url: https://us.api.konghq.com/v1
    description: United-States Production region
  - url: https://eu.api.konghq.com/v1
    description: Europe Production region
  - url: https://au.api.konghq.com/v1
    description: Australia Production region
  - url: https://me.api.konghq.com/v1
    description: Middle-East Production region
  - url: https://in.api.konghq.com/v1
    description: India Production region
  - url: https://sg.api.konghq.com/v1
    description: Singapore Production region
paths:
  /metrics:
    post:
      operationId: metrics
      summary: Query Metrics
      description: Post a query to the endpoint to retrieve aggregated metrics down to
        the minute. Data can be requested to group by any 2 dimensions, and any
        number of filter conditions.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MetricsV2Dto"
      responses:
        "200":
          description: Aggregated results of the query
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/MetricsResultV2"
        "400":
          description: Bad Request
          content:
            application/problem+json:
              examples:
                BadRequestExample:
                  $ref: "#/components/examples/BadRequestExample"
        "401":
          $ref: "#/components/responses/Unauthorized"
        "403":
          $ref: "#/components/responses/Forbidden"
      tags:
        - Metrics
components:
  schemas:
    MetricsV2Dto:
      description: A query to launch at the API
      type: object
      properties:
        metrics:
          description: List of aggregated metrics to collect across the requested time
            span. If no metrics are specified, request_count will be computed by
            default.
          type: array
          items:
            type: string
            enum:
              - kong_latency_average
              - kong_latency_p50
              - kong_latency_p95
              - kong_latency_p99
              - request_count
              - request_per_minute
              - request_size_average
              - request_size_p50
              - request_size_p95
              - request_size_p99
              - request_size_sum
              - response_latency_average
              - response_latency_p50
              - response_latency_p95
              - response_latency_p99
              - response_size_average
              - response_size_p50
              - response_size_p95
              - response_size_p99
              - response_size_sum
              - upstream_latency_average
              - upstream_latency_p50
              - upstream_latency_p95
              - upstream_latency_p99
          default:
            - request_count
          maxItems: 3
        dimensions:
          description: List of attributes or entity types to group by.
          type: array
          items:
            type: string
            enum:
              - api
              - api_package
              - api_product
              - api_product_version
              - application
              - consumer
              - control_plane
              - control_plane_group
              - country_code
              - data_plane_node
              - data_plane_node_version
              - gateway_service
              - portal
              - response_source
              - route
              - status_code
              - status_code_grouped
              - time
              - upstream_status_code
              - upstream_status_code_grouped
          example:
            - status_code_grouped
          maxItems: 2
        filters:
          $ref: "#/components/schemas/AdvancedFilters"
        granularity:
          $ref: "#/components/schemas/Granularity"
        time_range:
          $ref: "#/components/schemas/TimeRange"
        limit:
          description: Limits the number of distinct metric groups to return.
          type: number
          default: 50
          maximum: 1000
      example:
        time_range:
          type: relative
          time_range: 24h
          tz: EST
        dimensions:
          - time
          - gateway_service
        filters:
          - operator: in
            field: control_plane
            value:
              - d5ac5d88-efed-4e10-9dfe-0b0a6646c219
        granularity: hourly
        metrics:
          - request_count
          - response_latency_p99
      required:
        - metrics
    MetricsResultV2:
      description: >
        The result of a metrics query. Contains the data and metadata about the
        query.
      type: object
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/MetricsResult"
          readOnly: true
        meta:
          allOf:
            - $ref: "#/components/schemas/MetricsResponseMeta"
          readOnly: true
      example:
        data:
          - event:
              gateway_service: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055
              request_count: 1000
              response_latency_p99: 23
            timestamp: 2024-01-16T00:00:00Z
          - event:
              gateway_service: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111
              request_count: 10
              response_latency_p99: 339
            timestamp: 2024-01-16T01:00:00Z
        meta:
          start: 2024-01-16T00:00:00.000Z
          end: 2024-01-16T02:00:00.000Z
          display:
            gateway_service:
              d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111:
                id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111
                deleted: true
                name: Gateway Service Alpha
              d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055:
                id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055
                deleted: false
                name: Gateway Service Beta
          metric_units:
            request_count: count
            response_latency_p99: ms
          granularity_ms: 60000
          truncated: false
          limit: 50
          query_id: requested-query-id
      required:
        - data
        - meta
    AdvancedFilters:
      description: A list of filters to apply to the query.
      type: array
      items:
        discriminator:
          propertyName: field
          mapping:
            api: "#/components/schemas/MetricsApiFilterByField"
            api_package: "#/components/schemas/MetricsApiPackageFilterByField"
            api_product: "#/components/schemas/MetricsApiProductFilterByField"
            api_product_version: "#/components/schemas/MetricsApiProductVersionFilterByField"
            application: "#/components/schemas/MetricsApplicationFilterByField"
            consumer: "#/components/schemas/MetricsConsumerFilterByField"
            control_plane: "#/components/schemas/MetricsControlPlaneFilterByField"
            control_plane_group: "#/components/schemas/MetricsControlPlaneGroupFilterByField"
            country_code: "#/components/schemas/MetricsCountryCodeFilterByField"
            data_plane_node: "#/components/schemas/MetricsDataPlaneNodeFilterByField"
            data_plane_node_version: "#/components/schemas/MetricsDataPlaneNodeVersionFilterByField"
            gateway_service: "#/components/schemas/MetricsGatewayServiceFilterByField"
            portal: "#/components/schemas/MetricsPortalFilterByField"
            realm: "#/components/schemas/MetricsRealmFilterByField"
            response_source: "#/components/schemas/MetricsResponseSourceFilterByField"
            route: "#/components/schemas/MetricsRouteFilterByField"
            status_code: "#/components/schemas/MetricsStatusCodeFilterByField"
            status_code_grouped: "#/components/schemas/MetricsStatusCodeGroupedFilterByField"
            upstream_status_code: "#/components/schemas/MetricsUpstreamStatusCodeFilterByField"
            upstream_status_code_grouped: "#/components/schemas/MetricsUpstreamStatusCodeGr\
              oupedFilterByField"
        oneOf:
          - $ref: "#/components/schemas/MetricsApiFilterByField"
          - $ref: "#/components/schemas/MetricsApiPackageFilterByField"
          - $ref: "#/components/schemas/MetricsApiProductFilterByField"
          - $ref: "#/components/schemas/MetricsApiProductVersionFilterByField"
          - $ref: "#/components/schemas/MetricsApplicationFilterByField"
          - $ref: "#/components/schemas/MetricsConsumerFilterByField"
          - $ref: "#/components/schemas/MetricsControlPlaneFilterByField"
          - $ref: "#/components/schemas/MetricsControlPlaneGroupFilterByField"
          - $ref: "#/components/schemas/MetricsCountryCodeFilterByField"
          - $ref: "#/components/schemas/MetricsDataPlaneNodeFilterByField"
          - $ref: "#/components/schemas/MetricsDataPlaneNodeVersionFilterByField"
          - $ref: "#/components/schemas/MetricsGatewayServiceFilterByField"
          - $ref: "#/components/schemas/MetricsPortalFilterByField"
          - $ref: "#/components/schemas/MetricsRealmFilterByField"
          - $ref: "#/components/schemas/MetricsResponseSourceFilterByField"
          - $ref: "#/components/schemas/MetricsRouteFilterByField"
          - $ref: "#/components/schemas/MetricsStatusCodeFilterByField"
          - $ref: "#/components/schemas/MetricsStatusCodeGroupedFilterByField"
          - $ref: "#/components/schemas/MetricsUpstreamStatusCodeFilterByField"
          - $ref: "#/components/schemas/MetricsUpstreamStatusCodeGroupedFilterByField"
    Granularity:
      description: >
        Force time grouping into buckets of the specified duration.  Only has an
        effect if "time" is in the "dimensions" list.


        The granularity of the result may be coarser than requested.  The finest
        allowed granularity depends on the query's time range: data farther in
        the past may have coarser granularity.  The exact result granularity
        will be reported in the response `meta.granularity_ms` field.


        If granularity is not specified and "time" is in the dimensions list, a
        default will be chosen based on the time range requested.


        Different relative times support different granularities:
          - 15m => tenSecondly, thirtySecondly, minutely
          - 1h  => tenSecondly, thirtySecondly, minutely, fiveMinutely, tenMinutely
          - 6h  => thirtySecondly, minutely, fiveMinutely, tenMinutely, thirtyMinutely, hourly
          - 12h => minutely, fiveMinutely, tenMinutely, thirtyMinutely, hourly
          - 24h => fiveMinutely, tenMinutely, thirtyMinutely, hourly
          - 7d  => thirtyMinutely, hourly, twoHourly, twelveHourly, daily
          - 30d => hourly, twoHourly, twelveHourly, daily, weekly

        For special time ranges:
          - current_week, previous_week   => thirtyMinutely, hourly, twoHourly, twelveHourly, daily
          - current_month, previous_month => hourly, twoHourly, twelveHourly, daily, weekly

        For absolute time ranges, daily will be used.
      type: string
      enum:
        - tenSecondly
        - thirtySecondly
        - minutely
        - fiveMinutely
        - tenMinutely
        - thirtyMinutely
        - hourly
        - twoHourly
        - twelveHourly
        - daily
        - weekly
    TimeRange:
      description: The time range to query.
      default:
        type: relative
        time_range: 1h
      discriminator:
        propertyName: type
        mapping:
          relative: "#/components/schemas/MetricsRelativeTimeRangeDtoV2"
          absolute: "#/components/schemas/MetricsAbsoluteTimeRangeDtoV2"
      oneOf:
        - $ref: "#/components/schemas/MetricsRelativeTimeRangeDtoV2"
        - $ref: "#/components/schemas/MetricsAbsoluteTimeRangeDtoV2"
    MetricsResult:
      description: >
        A result with metrics grouped by the dimensions specified in the query,
        at a particular time


        The example represents a result group that has a summed request_count,
        and response_latency_p99 for a gateway_service at 2024-01-16T00:00:00Z.
      type: object
      properties:
        timestamp:
          type: string
          readOnly: true
        event:
          type: object
          readOnly: true
      example:
        event:
          gateway_service: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055
          request_count: 1000
          response_latency_p99: 23
        timestamp: 2024-01-16T00:00:00Z
      required:
        - timestamp
        - event
    MetricsResponseMeta:
      description: >
        Metadata about the query response. This includes the start and end times
        of the query, the granularity of the result, whether the result was
        truncated, the limit of the result, and the query_id.
      type: object
      properties:
        start:
          description: |
            Start of the query time range.
          type: string
          format: date-time
          readOnly: true
        end:
          description: |
            End of the query time range.
          type: string
          format: date-time
          readOnly: true
        display:
          description: >
            The blob represents how to interpret large UUID strings in the
            MetricsResult. The structure is records of dimension_id ->  ID ->
            entity metadata. Since entity names within Konnect may overlap, ids
            are returned and used for exact grouping. This blob may be used to
            join and display results in a more human friendly manner. Since IDs
            represent entities in the system at all points in time, historical
            data will still exist even if an entity is deleted. These such
            entities are marked with the `deleted` key.


            Another special case is the ____OTHER____ entity. When the limit of
            cardinality is reached for a second dimension, the system will group
            all other entities into the ____OTHER____ grouping. This prevents
            returning an overwhelming number of long tail entities.
          allOf:
            - $ref: "#/components/schemas/MetricsDisplayBlob"
          readOnly: true
        metric_units:
          description: >
            A meta object that describes how to interpret metric names and their
            associated unit.
          allOf:
            - $ref: "#/components/schemas/MetricUnits"
          readOnly: true
        granularity_ms:
          description: |
            The number of milliseconds per interval in a time series.
          type: number
          readOnly: true
        truncated:
          description: >
            Set true when the limit of cardinarlity is hit. For queries with 2
            dimensions, the limit truncates the first dimension, and then groups
            all other groupings for the second dimension.


            Example: limit of 2 for gateway_service and status_code would return
            2 gateway services maximum, and 2 status codes + ____OTHER____. The
            ____OTHER___ is representing all other status codes.
          type: boolean
          readOnly: true
        limit:
          description: |
            Applied query cardinality limit.
          type: number
          readOnly: true
        query_id:
          description: |
            An ID that can be used to reference the query.
          type: string
          readOnly: true
      example:
        start: 2024-01-16T18:00:00.000Z
        end: 2024-01-16T18:16:40.000Z
        display:
          gateway_service:
            d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111:
              id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111
              deleted: true
              name: Gateway Service Alpha
            d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055:
              id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055
              deleted: false
              name: Gateway Service Beta
        metric_units:
          request_count: count
          response_latency_p99: ms
        granularity_ms: 60000
        truncated: false
        limit: 50
        query_id: requested-query-id
      required:
        - start
        - end
        - display
        - metric_units
        - granularity_ms
        - truncated
        - limit
        - query_id
    UnauthorizedError:
      allOf:
        - $ref: "#/components/schemas/BaseError"
        - type: object
          properties:
            status:
              example: 401
            title:
              example: Unauthorized
            type:
              example: https://httpstatuses.com/401
            instance:
              example: kong:trace:1234567890
            detail:
              example: Invalid credentials
    ForbiddenError:
      allOf:
        - $ref: "#/components/schemas/BaseError"
        - type: object
          properties:
            status:
              example: 403
            title:
              example: Forbidden
            type:
              example: https://httpstatuses.com/403
            instance:
              example: kong:trace:1234567890
            detail:
              example: Forbidden
    MetricsApiFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - api
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - api
          required:
            - operator
            - field
      title: Filter by api
    MetricsApiPackageFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - api_package
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - api_package
          required:
            - operator
            - field
      title: Filter by api_package
    MetricsApiProductFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - api_product
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - api_product
          required:
            - operator
            - field
      title: Filter by api_product
    MetricsApiProductVersionFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - api_product_version
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - api_product_version
          required:
            - operator
            - field
      title: Filter by api_product_version
    MetricsApplicationFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - application
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - application
          required:
            - operator
            - field
      title: Filter by application
    MetricsConsumerFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: >
                The IDs to include in the results. Because gateway IDs are only
                unique within a given control plane, the filter values must be
                of the form `control_plane_id:field_id` or
                `control_plane_group_id:field_id` for data plane nodes within a
                control plane group.
              type: array
              items:
                $ref: "#/components/schemas/ScopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - consumer
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - consumer
          required:
            - operator
            - field
      title: Filter by consumer
    MetricsControlPlaneFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - control_plane
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - control_plane
          required:
            - operator
            - field
      title: Filter by control_plane
    MetricsControlPlaneGroupFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - control_plane_group
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - control_plane_group
          required:
            - operator
            - field
      title: Filter by control_plane_group
    MetricsCountryCodeFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The values to include in the results.
              type: array
              items:
                type: string
            field:
              description: The field to filter.
              type: string
              enum:
                - country_code
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - country_code
          required:
            - operator
            - field
      title: Filter by country_code
    MetricsDataPlaneNodeFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: >
                The IDs to include in the results. Because gateway IDs are only
                unique within a given control plane, the filter values must be
                of the form `control_plane_id:field_id` or
                `control_plane_group_id:field_id` for data plane nodes within a
                control plane group.
              type: array
              items:
                $ref: "#/components/schemas/ScopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - data_plane_node
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - data_plane_node
          required:
            - operator
            - field
      title: Filter by data_plane_node
    MetricsDataPlaneNodeVersionFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The values to include in the results.
              type: array
              items:
                type: string
            field:
              description: The field to filter.
              type: string
              enum:
                - data_plane_node_version
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - data_plane_node_version
          required:
            - operator
            - field
      title: Filter by data_plane_node_version
    MetricsGatewayServiceFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: >
                The IDs to include in the results. Because gateway IDs are only
                unique within a given control plane, the filter values must be
                of the form `control_plane_id:field_id` or
                `control_plane_group_id:field_id` for data plane nodes within a
                control plane group.
              type: array
              items:
                $ref: "#/components/schemas/ScopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - gateway_service
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - gateway_service
          required:
            - operator
            - field
      title: Filter by gateway_service
    MetricsPortalFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - portal
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - portal
          required:
            - operator
            - field
      title: Filter by portal
    MetricsRealmFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The IDs to include in the results.
              type: array
              items:
                $ref: "#/components/schemas/UnscopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - realm
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - realm
          required:
            - operator
            - field
      title: Filter by realm
    MetricsResponseSourceFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The values to include in the results.
              type: array
              items:
                type: string
            field:
              description: The field to filter.
              type: string
              enum:
                - response_source
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - response_source
          required:
            - operator
            - field
      title: Filter by response_source
    MetricsRouteFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: >
                The IDs to include in the results. Because gateway IDs are only
                unique within a given control plane, the filter values must be
                of the form `control_plane_id:field_id` or
                `control_plane_group_id:field_id` for data plane nodes within a
                control plane group.
              type: array
              items:
                $ref: "#/components/schemas/ScopedUuid"
            field:
              description: The field to filter.
              type: string
              enum:
                - route
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - route
          required:
            - operator
            - field
      title: Filter by route
    MetricsStatusCodeFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The codes to include in the results.
              type: array
              items:
                type: integer
                minimum: 0
                maximum: 999
            field:
              description: The field to filter.
              type: string
              enum:
                - status_code
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - status_code
          required:
            - operator
            - field
      title: Filter by status_code
    MetricsStatusCodeGroupedFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The code groups to include in the results.
              type: array
              items:
                type: string
                pattern: ^\d[xX][xX]$
            field:
              description: The field to filter.
              type: string
              enum:
                - status_code_grouped
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - status_code_grouped
          required:
            - operator
            - field
      title: Filter by status_code_grouped
    MetricsUpstreamStatusCodeFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The codes to include in the results.
              type: array
              items:
                type: integer
                minimum: 0
                maximum: 999
            field:
              description: The field to filter.
              type: string
              enum:
                - upstream_status_code
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - upstream_status_code
          required:
            - operator
            - field
      title: Filter by upstream_status_code
    MetricsUpstreamStatusCodeGroupedFilterByField:
      oneOf:
        - title: Multiselect filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterType"
            value:
              description: |
                The code groups to include in the results.
              type: array
              items:
                type: string
                pattern: ^\d[xX][xX]$
            field:
              description: The field to filter.
              type: string
              enum:
                - upstream_status_code_grouped
          required:
            - operator
            - value
            - field
        - title: Empty filters
          type: object
          properties:
            operator:
              $ref: "#/components/schemas/RequestsFilterTypeEmpty"
            field:
              description: The field to filter.
              type: string
              enum:
                - upstream_status_code_grouped
          required:
            - operator
            - field
      title: Filter by upstream_status_code_grouped
    MetricsRelativeTimeRangeDtoV2:
      description: A duration representing a relative-to-now span of time. Generally
        the start time is floored to the requested granularity. Eg 7d from now,
        with 1day granularity initiated at 2024-01-08T17:11:00+05:00 will query
        for the time range from 2024-01-01T00:00:00+05:00 to
        2024-01-08T17:11:00+05:00. The exact start and end timestamps are
        returned in the result query in the meta.start and meta.end fields. If
        the granularity for the previous query was 1hour, it would query a time
        range from 2024-01-01T17:00:00+05:00 to 2024-01-08T17:11:00+05:00.
      type: object
      properties:
        tz:
          type: string
          default: Etc/UTC
        type:
          type: string
          enum:
            - relative
        time_range:
          type: string
          default: 1h
          enum:
            - 15m
            - 1h
            - 6h
            - 12h
            - 24h
            - 7d
            - 30d
            - current_week
            - current_month
            - previous_week
            - previous_month
      required:
        - type
        - time_range
      title: Relative time range
    MetricsAbsoluteTimeRangeDtoV2:
      description: A duration representing an exact start and end time.
      type: object
      properties:
        tz:
          type: string
          default: Etc/UTC
        type:
          type: string
          enum:
            - absolute
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
      required:
        - type
      title: Absolute time range
    MetricsDisplayBlob:
      description: >
        The blob represents how to interpret large UUID strings in the
        MetricsResult. The structure is records of dimension_id ->  ID -> entity
        metadata. Since entity names within Konnect may overlap, ids are
        returned and used for exact grouping. This blob may be used to join and
        display results in a more human friendly manner. Since IDs represent
        entities in the system at all points in time, historical data will still
        exist even if an entity is deleted. These such entities are marked with
        the `deleted` key.


        Another special case is the ____OTHER____ entity. When the limit of
        cardinality is reached for a second dimension, the system will group all
        other entities into the ____OTHER____ grouping. This prevents returning
        an overwhelming number of long tail entities.
      type: object
      properties:
        api:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        api_package:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        api_product:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        api_product_version:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        application:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        consumer:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        control_plane:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        control_plane_group:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        country_code:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        data_plane_node:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        data_plane_node_version:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        gateway_service:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        portal:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        response_source:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        route:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        status_code:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        status_code_grouped:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        upstream_status_code:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
        upstream_status_code_grouped:
          type: object
          additionalProperties:
            $ref: "#/components/schemas/DisplayEntry"
      example:
        gateway_service:
          d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111:
            id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111
            deleted: true
            name: Gateway Service Alpha
          d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055:
            id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-1f2ea9215055
            deleted: false
            name: Gateway Service Beta
    MetricUnits:
      description: >
        A mapping of metric names to their associated unit. The keys are the
        metric names, and the values are the units. The possible units are: `ms`
        (Millisecond), `count`, and `bytes`
      type: object
      properties: {}
      example:
        request_count: count
        response_latency_p99: ms
    BaseError:
      description: standard error
      type: object
      properties:
        status:
          description: >
            The HTTP status code of the error. Useful when passing the response

            body to child properties in a frontend UI. Must be returned as an
            integer.
          type: integer
          readOnly: true
        title:
          description: |
            A short, human-readable summary of the problem. It should not
            change between occurences of a problem, except for localization.
            Should be provided as "Sentence case" for direct use in the UI.
          type: string
          readOnly: true
        type:
          description: The error type.
          type: string
          readOnly: true
        instance:
          description: |
            Used to return the correlation ID back to the user, in the format
            kong:trace:<correlation_id>. This helps us find the relevant logs
            when a customer reports an issue.
          type: string
          readOnly: true
        detail:
          description: >
            A human readable explanation specific to this occurence of the
            problem.

            This field may contain request/entity data to help the user
            understand

            what went wrong. Enclose variable values in square brackets. Should
            be

            provided as "Sentence case" for direct use in the UI.
          type: string
          readOnly: true
      required:
        - status
        - title
        - instance
        - detail
      title: Error
    RequestsFilterType:
      description: The type of filter to apply.  `in` filters will limit results to
        only the specified values, while `not_in` filters will exclude the
        specified values.
      type: string
      enum:
        - in
        - not_in
    UnscopedUuid:
      type: string
      pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
    RequestsFilterTypeEmpty:
      description: The type of filter to apply.
      type: string
      enum:
        - empty
        - not_empty
    ScopedUuid:
      type: string
      pattern: ^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$
    DisplayEntry:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        deleted:
          type: boolean
        is_other_group:
          type: boolean
      example:
        id: d5ac5d88-efed-4e10-9dfe-0b0a6646c219:bf16907c-8673-4f9d-aa83-111111111111
        deleted: true
        name: Gateway Service Alpha
      required:
        - id
        - name
  examples:
    BadRequestExample:
      value:
        status: 400
        title: Invalid Request
        instance: kong:trace:6591723055278037644
        detail: Invalid Parameters
        invalid_parameters:
          - field: time_range.time_range
            rule: unknown_property
            choices: []
            reason: property time_range should not exist
          - field: time_range.start_date
            rule: is_date
            choices: []
            reason: start must be a valid date in ISO format
          - field: time_range.end_date
            rule: is_date
            choices: []
            reason: end must be a valid date in ISO format
    UnauthorizedExample:
      value:
        status: 401
        title: Unauthorized
        instance: kong:trace:8347343766220159418
        detail: Unauthorized
    ForbiddenExample:
      value:
        status: 403
        title: Forbidden
        instance: kong:trace:2723154947768991354
        detail: You do not have permission to perform this action
  responses:
    Unauthorized:
      description: Unauthorized
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/UnauthorizedError"
          examples:
            UnauthorizedExample:
              $ref: "#/components/examples/UnauthorizedExample"
    Forbidden:
      description: Forbidden
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ForbiddenError"
          examples:
            UnauthorizedExample:
              $ref: "#/components/examples/ForbiddenExample"
```
