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

# aggregate alerts

> Aggregate using fields from response dto



## OpenAPI

````yaml /openapi.json post /api/v1/detector/alert/aggregation
openapi: 3.0.3
info:
  title: Extractor Project (dev)
  version: 0.0.649
servers: []
security: []
paths:
  /api/v1/detector/alert/aggregation:
    post:
      tags:
        - Detector Route
      summary: aggregate alerts
      description: Aggregate using fields from response dto
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OsQueryAggregationRequestDto'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OsAggregationDto'
      security:
        - SecurityScheme: []
components:
  schemas:
    OsQueryAggregationRequestDto:
      required:
        - aggregation
      type: object
      properties:
        query:
          description: >-
            Query string according to
            https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html
            with Default: auto_generate_synonyms_phrase_query=false,
            fuzzy_max_expansions=0, fuzzy_transpositions=false
          type: string
          example: address:0xdAC17F958D2ee523a2206206994597C13D831ec7
        timeseries:
          description: Timestamp ranges for search indices calculation
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/OsIndexRangeDto'
        trackTotalCount:
          format: int32
          description: >-
            Return total results up to 'count' value. If 0, then total tracking
            is disabled and return total=0
          default: 10000
          type: integer
        aggregation:
          description: Aggregations config for search results
          minItems: 1
          type: array
          items:
            $ref: '#/components/schemas/OsAggregationRequestDto'
    OsAggregationDto:
      type: object
      properties:
        total:
          format: int64
          description: Total amount of document available for this request
          type: integer
        data:
          description: Aggregations result for this request
          type: object
          additionalProperties: {}
    OsIndexRangeDto:
      required:
        - from
        - to
      type: object
      properties:
        from:
          format: int64
          description: From millis timestamp for search indices calculation
          minimum: 0
          type: integer
        to:
          format: int64
          description: To millis timestamp for search indices calculation
          minimum: 0
          type: integer
    OsAggregationRequestDto:
      required:
        - name
        - type
        - field
      type: object
      properties:
        name:
          description: Name of the aggregation, will be added as response key
          minLength: 1
          type: string
        type:
          description: Type of the aggregation
          type: string
          allOf:
            - $ref: '#/components/schemas/AggregationType'
        field:
          description: Field to use in aggregation
          minLength: 1
          type: string
        size:
          format: int32
          description: The number of aggregated buckets to return
          default: 5
          maximum: 100
          minimum: 1
          type: integer
          example: 5
        aggregation:
          description: Aggregations config for search results
          type: array
          items:
            $ref: '#/components/schemas/OsAggregationRequestDto'
        sort:
          description: Sorting for the search and top hits aggregation
          type: array
          items:
            $ref: '#/components/schemas/OsSortDto'
        query:
          description: Query to use in filter aggregation
          type: string
    AggregationType:
      enum:
        - TERM
        - TOP_HIT
        - FILTER
      type: string
    OsSortDto:
      required:
        - field
      type: object
      properties:
        field:
          description: Field name for sorting
          pattern: \S
          type: string
          example: timestamp
        mode:
          description: >-
            Used for array values sorting. The mode option controls what array
            value is picked for sorting the document it belongs to Default:
            ascending sort order is Min, descending order is Max
          type: string
          allOf:
            - $ref: '#/components/schemas/SortMode'
        order:
          description: 'Order for the sorting. Default: Asc'
          type: string
          allOf:
            - $ref: '#/components/schemas/SortOrder1'
    SortMode:
      enum:
        - Min
        - Max
        - Sum
        - Avg
        - Median
      type: string
    SortOrder1:
      enum:
        - Asc
        - Desc
      type: string
  securitySchemes:
    SecurityScheme:
      type: http
      description: Authentication
      scheme: bearer
      bearerFormat: JWT

````