For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/api/latest/ci-visibility-tests/aggregate-tests-events.md. A documentation index is available at /llms.txt.
Language
Datadog site

Aggregate tests events

POSThttps://api.datadoghq.com/api/v2/ci/tests/analytics/aggregatehttps://api.us3.datadoghq.com/api/v2/ci/tests/analytics/aggregatehttps://api.us5.datadoghq.com/api/v2/ci/tests/analytics/aggregatehttps://api.datadoghq.eu/api/v2/ci/tests/analytics/aggregatehttps://api.ap1.datadoghq.com/api/v2/ci/tests/analytics/aggregatehttps://api.ap2.datadoghq.com/api/v2/ci/tests/analytics/aggregatehttps://api.uk1.datadoghq.com/api/v2/ci/tests/analytics/aggregatehttps://api.ddog-gov.com/api/v2/ci/tests/analytics/aggregatehttps://api.us2.ddog-gov.com/api/v2/ci/tests/analytics/aggregate

Overview

The API endpoint to aggregate CI Visibility test events into buckets of computed metrics and timeseries.

This endpoint requires any of the following permissions:

  • ci_visibility_read
  • test_optimization_read

OAuth apps require one of the following authorization scopes to access this endpoint: ci_visibility_read, test_optimization_read.

Request

Body Data (required)

Field
Type
Description
compute
[object]

The list of metrics or timeseries to compute for the retrieved buckets.

filter
object

The search and filter query settings.

group_by
[object]

The rules for the group-by.

options
object

Global query options that are used during the query. Only supply timezone or time offset, not both. Otherwise, the query fails.

Response

OK

The response object for the test events aggregate API endpoint.

Field
Type
Description
data
object

The query results.

links
object

Links attributes.

meta
object

The metadata associated with a request.

Code Example

Aggregate tests events returns "OK" response
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF
# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/ci/tests/analytics/aggregate" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "compute": [
    {
      "aggregation": "count",
      "metric": "@test.is_flaky",
      "type": "total"
    }
  ],
  "filter": {
    "from": "now-15m",
    "query": "@language:(python OR go)",
    "to": "now"
  },
  "group_by": [
    {
      "facet": "@git.branch",
      "limit": 10,
      "sort": {
        "order": "asc"
      },
      "total": false
    }
  ],
  "options": {
    "timezone": "GMT"
  }
}
EOF