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

# Query Custom Metrics



## OpenAPI

````yaml https://api.galileo.ai/public/v2/openapi.json post /v2/projects/{project_id}/metrics/custom_search
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: https://api.galileo.ai
    description: Galileo Public APIs - galileo-v2
security: []
paths:
  /v2/projects/{project_id}/metrics/custom_search:
    post:
      tags:
        - trace
      summary: Query Custom Metrics
      operationId: query_custom_metrics_v2_projects__project_id__metrics_custom_search_post
      parameters:
        - name: project_id
          in: path
          required: true
          schema:
            type: string
            format: uuid4
            title: Project Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LogRecordsCustomMetricsQueryRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LogRecordsMetricsResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - APIKeyHeader: []
        - OAuth2PasswordBearer: []
        - HTTPBasic: []
components:
  schemas:
    LogRecordsCustomMetricsQueryRequest:
      properties:
        log_stream_id:
          anyOf:
            - type: string
              format: uuid4
            - type: 'null'
          title: Log Stream Id
          description: Log stream id associated with the traces.
        experiment_id:
          anyOf:
            - type: string
              format: uuid4
            - type: 'null'
          title: Experiment Id
          description: Experiment id associated with the traces.
        metrics_testing_id:
          anyOf:
            - type: string
              format: uuid4
            - type: 'null'
          title: Metrics Testing Id
          description: Metrics testing id associated with the traces.
        filter_tree:
          anyOf:
            - $ref: >-
                #/components/schemas/FilterExpression_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
            - type: 'null'
          description: Filter expression tree for complex filtering
        start_time:
          type: string
          format: date-time
          title: Start Time
          description: Include traces from this time onward.
        end_time:
          type: string
          format: date-time
          title: End Time
          description: Include traces up to this time.
        interval_minutes:
          type: integer
          title: Interval Minutes
          description: Time interval in minutes for bucketing
          default: 5
        metric_details:
          items:
            $ref: '#/components/schemas/MetricAggregationDetail'
          type: array
          maxItems: 100
          title: Metric Details
          description: >-
            List of metrics to aggregate with their widget IDs and aggregation
            types (max 100)
        group_by:
          anyOf:
            - type: string
            - type: 'null'
          title: Group By
          description: Column to group by
      type: object
      required:
        - start_time
        - end_time
        - metric_details
      title: LogRecordsCustomMetricsQueryRequest
      examples:
        - end_time: '2024-01-07T23:59:59Z'
          filter_tree:
            and_:
              - filter:
                  case_sensitive: true
                  name: input
                  operator: contains
                  type: text
                  value: customer
          group_by: model
          interval_minutes: 1440
          log_stream_id: c5fef527-51f6-49d0-800a-1859b678a098
          metric_details:
            - aggregation: Sum
              id: w1
              metric_name: num_total_tokens
            - aggregation: Average
              id: w2
              metric_name: toxicity
          start_time: '2024-01-01T00:00:00Z'
    LogRecordsMetricsResponse:
      properties:
        group_by_columns:
          items:
            type: string
          type: array
          title: Group By Columns
        aggregate_metrics:
          additionalProperties:
            anyOf:
              - type: number
              - type: integer
              - additionalProperties:
                  type: integer
                type: object
          type: object
          title: Aggregate Metrics
        bucketed_metrics:
          additionalProperties:
            items:
              $ref: '#/components/schemas/BucketedMetrics'
            type: array
          type: object
          title: Bucketed Metrics
        ems_captured_error:
          type: boolean
          title: Ems Captured Error
          description: Whether any EMS error codes were encountered in the queried metrics
          default: false
        standard_errors:
          anyOf:
            - additionalProperties:
                $ref: '#/components/schemas/StandardError'
              type: object
            - type: 'null'
          title: Standard Errors
          description: Structured EMS errors for each error code encountered, keyed by code
      type: object
      required:
        - group_by_columns
        - aggregate_metrics
        - bucketed_metrics
      title: LogRecordsMetricsResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    FilterExpression_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input:
      anyOf:
        - $ref: >-
            #/components/schemas/FilterLeaf_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____
        - $ref: >-
            #/components/schemas/AndNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
        - $ref: >-
            #/components/schemas/OrNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
        - $ref: >-
            #/components/schemas/NotNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
    MetricAggregationDetail:
      properties:
        id:
          type: string
          title: Id
          description: Identifier for the metric in the response (e.g., 'w1', 'w2')
        metric_name:
          type: string
          title: Metric Name
          description: Name of the metric to aggregate
        aggregation:
          $ref: '#/components/schemas/MetricAggregation'
          description: Aggregation type to apply
      type: object
      required:
        - id
        - metric_name
        - aggregation
      title: MetricAggregationDetail
    BucketedMetrics:
      properties:
        start_bucket_time:
          type: string
          format: date-time
          title: Start Bucket Time
        end_bucket_time:
          type: string
          format: date-time
          title: End Bucket Time
      additionalProperties: true
      type: object
      required:
        - start_bucket_time
        - end_bucket_time
      title: BucketedMetrics
    StandardError:
      properties:
        error_code:
          type: integer
          title: Error Code
        error_type:
          $ref: '#/components/schemas/ErrorType'
        error_group:
          type: string
          title: Error Group
        severity:
          $ref: '#/components/schemas/ErrorSeverity'
        message:
          type: string
          title: Message
        user_action:
          anyOf:
            - type: string
            - type: 'null'
          title: User Action
        documentation_link:
          anyOf:
            - type: string
              maxLength: 2083
              minLength: 1
              format: uri
            - type: 'null'
          title: Documentation Link
        retriable:
          type: boolean
          title: Retriable
          default: false
        blocking:
          type: boolean
          title: Blocking
          default: false
        http_status_code:
          anyOf:
            - type: integer
            - type: 'null'
          title: Http Status Code
        source_service:
          anyOf:
            - type: string
            - type: 'null'
          title: Source Service
        context:
          additionalProperties: true
          type: object
          title: Context
      type: object
      required:
        - error_code
        - error_type
        - error_group
        - severity
        - message
      title: StandardError
    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
    FilterLeaf_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____:
      properties:
        filter:
          oneOf:
            - $ref: '#/components/schemas/LogRecordsIDFilter'
            - $ref: '#/components/schemas/LogRecordsDateFilter'
            - $ref: '#/components/schemas/LogRecordsNumberFilter'
            - $ref: '#/components/schemas/LogRecordsBooleanFilter'
            - $ref: '#/components/schemas/LogRecordsCollectionFilter'
            - $ref: '#/components/schemas/LogRecordsTextFilter'
            - $ref: '#/components/schemas/LogRecordsFullyAnnotatedFilter'
          title: Filter
          discriminator:
            propertyName: type
            mapping:
              boolean:
                $ref: '#/components/schemas/LogRecordsBooleanFilter'
              collection:
                $ref: '#/components/schemas/LogRecordsCollectionFilter'
              date:
                $ref: '#/components/schemas/LogRecordsDateFilter'
              fully_annotated:
                $ref: '#/components/schemas/LogRecordsFullyAnnotatedFilter'
              id:
                $ref: '#/components/schemas/LogRecordsIDFilter'
              number:
                $ref: '#/components/schemas/LogRecordsNumberFilter'
              text:
                $ref: '#/components/schemas/LogRecordsTextFilter'
      type: object
      required:
        - filter
      title: >-
        FilterLeaf[Annotated[Union[LogRecordsIDFilter, LogRecordsDateFilter,
        LogRecordsNumberFilter, LogRecordsBooleanFilter,
        LogRecordsCollectionFilter, LogRecordsTextFilter,
        LogRecordsFullyAnnotatedFilter], FieldInfo(annotation=NoneType,
        required=True, discriminator='type')]]
    AndNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input:
      properties:
        and:
          items:
            anyOf:
              - $ref: >-
                  #/components/schemas/FilterLeaf_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____
              - $ref: >-
                  #/components/schemas/AndNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
              - $ref: >-
                  #/components/schemas/OrNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
              - $ref: >-
                  #/components/schemas/NotNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
          type: array
          title: And
      type: object
      required:
        - and
      title: >-
        AndNode[Annotated[Union[LogRecordsIDFilter, LogRecordsDateFilter,
        LogRecordsNumberFilter, LogRecordsBooleanFilter,
        LogRecordsCollectionFilter, LogRecordsTextFilter,
        LogRecordsFullyAnnotatedFilter], FieldInfo(annotation=NoneType,
        required=True, discriminator='type')]]
    OrNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input:
      properties:
        or:
          items:
            anyOf:
              - $ref: >-
                  #/components/schemas/FilterLeaf_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____
              - $ref: >-
                  #/components/schemas/AndNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
              - $ref: >-
                  #/components/schemas/OrNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
              - $ref: >-
                  #/components/schemas/NotNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
          type: array
          title: Or
      type: object
      required:
        - or
      title: >-
        OrNode[Annotated[Union[LogRecordsIDFilter, LogRecordsDateFilter,
        LogRecordsNumberFilter, LogRecordsBooleanFilter,
        LogRecordsCollectionFilter, LogRecordsTextFilter,
        LogRecordsFullyAnnotatedFilter], FieldInfo(annotation=NoneType,
        required=True, discriminator='type')]]
    NotNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input:
      properties:
        not:
          anyOf:
            - $ref: >-
                #/components/schemas/FilterLeaf_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____
            - $ref: >-
                #/components/schemas/AndNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
            - $ref: >-
                #/components/schemas/OrNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
            - $ref: >-
                #/components/schemas/NotNode_Annotated_Union_LogRecordsIDFilter__LogRecordsDateFilter__LogRecordsNumberFilter__LogRecordsBooleanFilter__LogRecordsCollectionFilter__LogRecordsTextFilter__LogRecordsFullyAnnotatedFilter___FieldInfo_annotation_NoneType__required_True__discriminator__type____-Input
          title: Not
      type: object
      required:
        - not
      title: >-
        NotNode[Annotated[Union[LogRecordsIDFilter, LogRecordsDateFilter,
        LogRecordsNumberFilter, LogRecordsBooleanFilter,
        LogRecordsCollectionFilter, LogRecordsTextFilter,
        LogRecordsFullyAnnotatedFilter], FieldInfo(annotation=NoneType,
        required=True, discriminator='type')]]
    MetricAggregation:
      type: string
      enum:
        - Count
        - Sum
        - Average
        - Min
        - Max
        - P50
        - P90
        - P95
        - P99
        - PercentageFalse
        - PercentageTrue
      title: MetricAggregation
    ErrorType:
      type: string
      enum:
        - llm_api_error
        - credentials_error
        - data_validation_error
        - configuration_error
        - permission_error
        - not_found_error
        - workflow_error
        - system_error
        - not_applicable_reason
        - uncataloged_error
      title: ErrorType
    ErrorSeverity:
      type: string
      enum:
        - low
        - medium
        - high
        - critical
      title: ErrorSeverity
      description: Error severity levels for catalog entries.
    LogRecordsIDFilter:
      properties:
        column_id:
          type: string
          title: Column Id
          description: ID of the column to filter.
        operator:
          type: string
          enum:
            - eq
            - ne
            - one_of
            - not_in
            - contains
          title: Operator
          default: eq
        value:
          anyOf:
            - type: string
              format: uuid4
            - items:
                anyOf:
                  - type: string
                    format: uuid4
                  - type: string
              type: array
            - type: string
          title: Value
        type:
          type: string
          const: id
          title: Type
          default: id
      type: object
      required:
        - column_id
        - value
      title: LogRecordsIDFilter
    LogRecordsDateFilter:
      properties:
        column_id:
          type: string
          title: Column Id
          description: ID of the column to filter.
        operator:
          type: string
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
          title: Operator
        value:
          type: string
          format: date-time
          title: Value
        type:
          type: string
          const: date
          title: Type
          default: date
      type: object
      required:
        - column_id
        - operator
        - value
      title: LogRecordsDateFilter
    LogRecordsNumberFilter:
      properties:
        column_id:
          type: string
          title: Column Id
          description: ID of the column to filter.
        operator:
          type: string
          enum:
            - eq
            - ne
            - gt
            - gte
            - lt
            - lte
            - between
          title: Operator
        value:
          anyOf:
            - type: integer
            - type: number
            - items:
                type: integer
              type: array
            - items:
                type: number
              type: array
          title: Value
        type:
          type: string
          const: number
          title: Type
          default: number
      type: object
      required:
        - column_id
        - operator
        - value
      title: LogRecordsNumberFilter
    LogRecordsBooleanFilter:
      properties:
        column_id:
          type: string
          title: Column Id
          description: ID of the column to filter.
        operator:
          type: string
          enum:
            - eq
            - ne
          title: Operator
          default: eq
        value:
          type: boolean
          title: Value
        type:
          type: string
          const: boolean
          title: Type
          default: boolean
      type: object
      required:
        - column_id
        - value
      title: LogRecordsBooleanFilter
    LogRecordsCollectionFilter:
      properties:
        column_id:
          type: string
          title: Column Id
          description: ID of the column to filter.
        operator:
          type: string
          enum:
            - eq
            - contains
            - one_of
            - not_in
          title: Operator
        value:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
          title: Value
        case_sensitive:
          type: boolean
          title: Case Sensitive
          default: true
        type:
          type: string
          const: collection
          title: Type
          default: collection
      type: object
      required:
        - column_id
        - operator
        - value
      title: LogRecordsCollectionFilter
    LogRecordsTextFilter:
      properties:
        column_id:
          type: string
          title: Column Id
          description: ID of the column to filter.
        operator:
          type: string
          enum:
            - eq
            - ne
            - contains
            - one_of
            - not_in
          title: Operator
        value:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
          title: Value
        case_sensitive:
          type: boolean
          title: Case Sensitive
          default: true
        type:
          type: string
          const: text
          title: Type
          default: text
      type: object
      required:
        - column_id
        - operator
        - value
      title: LogRecordsTextFilter
    LogRecordsFullyAnnotatedFilter:
      properties:
        column_id:
          type: string
          const: fully_annotated
          title: Column Id
          description: >-
            Queue-scoped filter identifier. This filter only works for
            annotation-queue searches that provide queue context.
          default: fully_annotated
        type:
          type: string
          const: fully_annotated
          title: Type
          default: fully_annotated
        user_ids:
          anyOf:
            - items:
                type: string
                format: uuid4
              type: array
              minItems: 1
            - type: 'null'
          title: User Ids
          description: >-
            Optional queue member IDs to require for full annotation in a
            queue-scoped search. If omitted, all tracked queue members visible
            to the requester are used.
      type: object
      title: LogRecordsFullyAnnotatedFilter
      description: Queue-scoped filter for records rated across all queue templates.
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: Galileo-API-Key
    OAuth2PasswordBearer:
      type: oauth2
      flows:
        password:
          scopes: {}
          tokenUrl: https://api.galileo.ai/login
    HTTPBasic:
      type: http
      scheme: basic

````