> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unomiq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Trace Metrics

> Get aggregated metrics for traces.

Requires a valid JWT token with the `read:traces` permission.

Computes statistical distributions (mean, median, percentiles, min, max, stddev)
for trace duration, cost per trace, and spans per trace.

Supports the same filter expressions as the `engine/query` endpoint.

Returns trace metrics with duration, cost, and volume statistics.



## OpenAPI

````yaml POST /engine/metrics
openapi: 3.1.0
info:
  title: Unomiq Engine API
  description: >-

    API for managing OpenTelemetry data, queries and boards.


    ## Authentication


    All API endpoints require authentication via JWT token in the Authorization
    header:


    ```

    Authorization: Bearer <your_jwt_token>

    ```


    Obtain your JWT token from the authentication service and include it in all
    requests.
        
  version: 1.0.0
servers:
  - url: https://engine-api.unomiq.com
    description: Production
security: []
paths:
  /engine/metrics:
    post:
      tags:
        - engine
      summary: Get Trace Metrics
      description: >-
        Get aggregated metrics for traces.


        Requires a valid JWT token with the `read:traces` permission.


        Computes statistical distributions (mean, median, percentiles, min, max,
        stddev)

        for trace duration, cost per trace, and spans per trace.


        Supports the same filter expressions as the `engine/query` endpoint.


        Returns trace metrics with duration, cost, and volume statistics.
      operationId: get_trace_metrics_engine_metrics_post
      parameters:
        - name: start_time
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: Start datetime (inclusive)
            examples:
              - '2025-01-15T00:00:00Z'
            title: Start Time
          description: Start datetime (inclusive)
        - name: end_time
          in: query
          required: true
          schema:
            type: string
            format: date-time
            description: End datetime (exclusive)
            examples:
              - '2025-01-16T00:00:00Z'
            title: End Time
          description: End datetime (exclusive)
        - name: X-Unomiq-App-Id
          in: header
          required: true
          schema:
            type: string
            title: X-Unomiq-App-Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryFilter'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TraceMetrics'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    QueryFilter:
      properties:
        filter:
          anyOf:
            - $ref: '#/components/schemas/Condition'
            - $ref: '#/components/schemas/AndGroup'
            - $ref: '#/components/schemas/OrGroup'
            - type: 'null'
          title: Filter
          description: Filter expression with nested AND/OR conditions
          examples:
            - and:
                - field: span_attributes.http.status_code
                  op: gte
                  value: '200'
                - field: span_attributes.http.status_code
                  op: lte
                  value: '299'
                - or:
                    - field: span_kind
                      op: eq
                      value: SERVER
                    - field: span_kind
                      op: eq
                      value: CLIENT
      type: object
      title: QueryFilter
      description: Request model for query filter.
    TraceMetrics:
      properties:
        trace_count:
          type: integer
          title: Trace Count
        duration:
          $ref: '#/components/schemas/DistributionStats'
        cost:
          $ref: '#/components/schemas/DistributionStats'
        spans_per_trace:
          $ref: '#/components/schemas/DistributionStats'
      type: object
      required:
        - trace_count
        - duration
        - cost
        - spans_per_trace
      title: TraceMetrics
      description: Aggregated metrics for traces.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Condition:
      properties:
        field:
          type: string
          pattern: >-
            ^(span_attributes\.[a-zA-Z0-9._]+|resource_attributes\.[a-zA-Z0-9._]+|trace_id|span_id|span_kind|span_name|service_name|unit|parent_unit|duration_ms|cost|billing\.resource_type|billing\.resource_name|billing\.service_id|billing\.service_name|billing\.sku_id|billing\.sku_name|billing\.region|usage\.amount|usage\.unit)$
          title: Field
          description: >-
            Field to filter on. Use dot notation for nested fields (e.g.,
            'billing.service_name', 'billing.region', 'usage.amount',
            'span_attributes.http.method', 'resource_attributes.service.name')
          examples:
            - span_attributes.http.method
            - resource_attributes.service.name
            - span_kind
            - service_name
            - billing.region
        op:
          $ref: '#/components/schemas/QueryOperator'
          description: Comparison operator
          examples:
            - eq
            - contains
            - gte
        value:
          type: string
          title: Value
          description: Value to compare against
          examples:
            - GET
            - my-service
            - SERVER
      type: object
      required:
        - field
        - op
        - value
      title: Condition
      description: A single filter condition.
    AndGroup:
      properties:
        and:
          items:
            anyOf:
              - $ref: '#/components/schemas/Condition'
              - $ref: '#/components/schemas/OrGroup'
              - $ref: '#/components/schemas/AndGroup'
          type: array
          title: And
          description: List of conditions to combine with AND
      type: object
      required:
        - and
      title: AndGroup
      description: A group of conditions combined with AND logic.
    OrGroup:
      properties:
        or:
          items:
            anyOf:
              - $ref: '#/components/schemas/Condition'
              - $ref: '#/components/schemas/AndGroup'
              - $ref: '#/components/schemas/OrGroup'
          type: array
          title: Or
          description: List of conditions to combine with OR
      type: object
      required:
        - or
      title: OrGroup
      description: A group of conditions combined with OR logic.
    DistributionStats:
      properties:
        mean:
          type: number
          title: Mean
        median:
          type: number
          title: Median
        p50:
          type: number
          title: P50
        p90:
          type: number
          title: P90
        p95:
          type: number
          title: P95
        p99:
          type: number
          title: P99
        min:
          type: number
          title: Min
        max:
          type: number
          title: Max
        stddev:
          type: number
          title: Stddev
      type: object
      required:
        - mean
        - median
        - p50
        - p90
        - p95
        - p99
        - min
        - max
        - stddev
      title: DistributionStats
      description: Statistical distribution metrics.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    QueryOperator:
      type: string
      enum:
        - eq
        - neq
        - contains
        - starts_with
        - ends_with
        - gt
        - lt
        - gte
        - lte
      title: QueryOperator
      description: Supported query operators.
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````