---
title: "Aggregate pipelines events"
method: POST
path: "/api/v2/ci/pipelines/analytics/aggregate"
tags: ["CI Visibility Pipelines"]
---

# Aggregate pipelines events

`POST /api/v2/ci/pipelines/analytics/aggregate`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/ci/pipelines/analytics/aggregate`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `ci_visibility_read`

Use this API endpoint to aggregate CI Visibility pipeline events into buckets of computed metrics and timeseries.

## Request body

- CIAppPipelinesAggregateRequest: The object sent with the request to retrieve aggregation buckets of pipeline events from your organization.
  - `compute` CIAppCompute[]: The list of metrics or timeseries to compute for the retrieved buckets.
    - `aggregation` 'count' | 'cardinality' | 'pc75' | 'pc90' | 'pc95' | 'pc98' | 'pc99' | 'sum' | 'min' | 'max' | 'avg' | 'median' | 'latest' | 'earliest' | 'most_frequent' | 'delta', required: An aggregation function.
    - `interval` string: The time buckets' size (only used for type=timeseries) Defaults to a resolution of 150 points.
    - `metric` string: The metric to use.
    - `type` 'timeseries' | 'total': The type of compute.
  - `filter` CIAppPipelinesQueryFilter: The search and filter query settings.
    - `from` string: The minimum time for the requested events; supports date, math, and regular timestamps (in milliseconds).
    - `query` string: The search query following the CI Visibility Explorer search syntax.
    - `to` string: The maximum time for the requested events, supports date, math, and regular timestamps (in milliseconds).
  - `group_by` CIAppPipelinesGroupBy[]: The rules for the group-by.
    - `facet` string, required: The name of the facet to use (required).
    - `histogram` CIAppGroupByHistogram: Used to perform a histogram computation (only for measure facets). At most, 100 buckets are allowed, the number of buckets is `(max - min)/interval`.
      - `interval` number, double, required: The bin size of the histogram buckets.
      - `max` number, double, required: The maximum value for the measure used in the histogram (values greater than this one are filtered out).
      - `min` number, double, required: The minimum value for the measure used in the histogram (values smaller than this one are filtered out).
    - `limit` integer: The maximum buckets to return for this group-by.
    - `missing` union: The value to use for logs that don't have the facet used to group-by.
      - string: The missing value to use if there is a string valued facet.
      - number, double: The missing value to use if there is a number valued facet.
    - `sort` CIAppAggregateSort: A sort rule. The `aggregation` field is required when `type` is `measure`.
      - `aggregation` 'count' | 'cardinality' | 'pc75' | 'pc90' | 'pc95' | 'pc98' | 'pc99' | 'sum' | 'min' | 'max' | 'avg' | 'median' | 'latest' | 'earliest' | 'most_frequent' | 'delta': An aggregation function.
      - `metric` string: The metric to sort by (only used for `type=measure`).
      - `order` 'asc' | 'desc': The order to use, ascending or descending.
      - `type` 'alphabetical' | 'measure': The type of sorting algorithm.
    - `total` union: A resulting object to put the given computes in over all the matching records.
      - boolean: If set to true, creates an additional bucket labeled "$facet_total".
      - string: A string to use as the key value for the total bucket.
      - number, double: A number to use as the key value for the total bucket.
  - `options` CIAppQueryOptions: Global query options that are used during the query. Only supply timezone or time offset, not both. Otherwise, the query fails.
    - `time_offset` integer: The time offset (in seconds) to apply to the query.
    - `timezone` string: The timezone can be specified as GMT, UTC, an offset from UTC (like UTC+1), or as a Timezone Database identifier (like America/New_York).

## Response `200`

OK

- CIAppPipelinesAnalyticsAggregateResponse: The response object for the pipeline events aggregate API endpoint.
  - `data` CIAppPipelinesAggregationBucketsResponse: The query results.
    - `buckets` CIAppPipelinesBucketResponse[]: The list of matching buckets, one item per bucket.
      - `by` object: The key-value pairs for each group-by.
      - `computes` CIAppComputes: A map of the metric name to value for regular compute, or a list of values for a timeseries.
  - `links` CIAppResponseLinks: Links attributes.
    - `next` string: Link for the next set of results. The request can also be made using the POST endpoint.
  - `meta` CIAppResponseMetadata: The metadata associated with a request.
    - `elapsed` integer: The time elapsed in milliseconds.
    - `request_id` string: The identifier of the request.
    - `status` 'done' | 'timeout': The status of the response.
    - `warnings` CIAppWarning[]: A list of warnings (non-fatal errors) encountered. Partial results may return if warnings are present in the response.
      - `code` string: A unique code for this type of warning.
      - `detail` string: A detailed explanation of this specific warning.
      - `title` string: A short human-readable summary of the warning.

## Other responses

- `400`: Bad Request
- `403`: Not Authorized
- `429`: Too many requests

---

[API](https://skmtc.dev/datadog/apis/datadog-api-v2-collection.md) - [All operations](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/llms.txt) - [OpenAPI document](https://skmtc.dev/datadog/apis/datadog-api-v2-collection/revisions/da68bf029e4c?raw)
