---
title: Query aggregated long tasks
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > RUM Insights
---

# Query aggregated long tasks{% #query-aggregated-long-tasks %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                                      |
| ----------------- | --------------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/rum/query/insight/aggregated_long_tasks |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/rum/query/insight/aggregated_long_tasks |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/rum/query/insight/aggregated_long_tasks      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/rum/query/insight/aggregated_long_tasks      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/rum/query/insight/aggregated_long_tasks  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/rum/query/insight/aggregated_long_tasks     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/rum/query/insight/aggregated_long_tasks |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/rum/query/insight/aggregated_long_tasks |

### Overview

Get aggregated long task data for a RUM view, grouped by invoker type and sampled across multiple view instances. This endpoint requires the `rum_apps_read` permission.

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                            | Type   | Description                                                                                                                                                                  |
| ------------ | -------------------------------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]           | object | Data envelope for an aggregated long tasks request.                                                                                                                          |
| data         | attributes [*required*]     | object | Attributes for an aggregated long tasks query.                                                                                                                               |
| attributes   | application_id [*required*] | string | The RUM application ID to analyze.                                                                                                                                           |
| attributes   | criteria                         | object | Performance criteria to filter view instances by a metric threshold.                                                                                                         |
| criteria     | max                              | double | Maximum threshold in seconds (inclusive).                                                                                                                                    |
| criteria     | metric [*required*]         | enum   | Performance metric used to filter view instances by threshold. Allowed enum values: `loading_time,largest_contentful_paint,first_contentful_paint,interaction_to_next_paint` |
| criteria     | min                              | double | Minimum threshold in seconds (inclusive).                                                                                                                                    |
| attributes   | filter                           | string | RUM query string to filter events (for example, @session.type:user @geo.country:US).                                                                                         |
| attributes   | from [*required*]           | int64  | Start of the time range as a Unix timestamp in seconds.                                                                                                                      |
| attributes   | sample_size [*required*]    | int32  | Number of view instances to sample, between 1 and 500.                                                                                                                       |
| attributes   | to [*required*]             | int64  | End of the time range as a Unix timestamp in seconds.                                                                                                                        |
| attributes   | view_name [*required*]      | string | The RUM view name to analyze (for example, /account/login).                                                                                                                  |
| data         | type [*required*]           | enum   | The JSON:API type for aggregated long tasks requests. Allowed enum values: `aggregated_long_tasks`                                                                           |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "application_id": "ccbc53b1-74f2-496b-bdd7-9a8fa7b7376b",
      "criteria": {
        "max": 5,
        "metric": "largest_contentful_paint",
        "min": 2.5
      },
      "filter": "@session.type:user",
      "from": 1762437564,
      "sample_size": 20,
      "to": 1762523964,
      "view_name": "/account/login(/:type)"
    },
    "type": "aggregated_long_tasks"
  }
}
```

{% /tab %}

### Response

{% tab title="201" %}
Successful response
{% tab title="Model" %}
Response body for the aggregated long tasks endpoint.

| Parent field                  | Field                                        | Type     | Description                                                                                                                                                                  |
| ----------------------------- | -------------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                               | data [*required*]                       | object   | Data envelope for an aggregated long tasks response.                                                                                                                         |
| data                          | attributes [*required*]                 | object   | Attributes of an aggregated long tasks response.                                                                                                                             |
| attributes                    | application_id [*required*]             | string   | The RUM application ID that was analyzed.                                                                                                                                    |
| attributes                    | criteria                                     | object   | Performance criteria to filter view instances by a metric threshold.                                                                                                         |
| criteria                      | max                                          | double   | Maximum threshold in seconds (inclusive).                                                                                                                                    |
| criteria                      | metric [*required*]                     | enum     | Performance metric used to filter view instances by threshold. Allowed enum values: `loading_time,largest_contentful_paint,first_contentful_paint,interaction_to_next_paint` |
| criteria                      | min                                          | double   | Minimum threshold in seconds (inclusive).                                                                                                                                    |
| attributes                    | from [*required*]                       | int64    | Start of the analyzed time range as a Unix timestamp in seconds.                                                                                                             |
| attributes                    | long_tasks_by_invoker_type [*required*] | [object] | Long task statistics grouped by invoker type, sorted by impact score descending.                                                                                             |
| long_tasks_by_invoker_type    | criteria_view_occurrences                    | int32    | Number of sampled views where this invoker type had long tasks contributing to the criteria metric.                                                                          |
| long_tasks_by_invoker_type    | impact_score                                 | double   | Rank-product impact score combining view frequency and blocking time severity.                                                                                               |
| long_tasks_by_invoker_type    | invoker_type [*required*]               | string   | Category of the long task invoker (for example, resolve-promise, user-callback).                                                                                             |
| long_tasks_by_invoker_type    | stats_per_view [*required*]             | object   | Statistical distributions of long task metrics computed per view across sampled views.                                                                                       |
| stats_per_view                | fcp_blocking_time_ms                         | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| fcp_blocking_time_ms          | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| fcp_blocking_time_ms          | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| fcp_blocking_time_ms          | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | fcp_count                                    | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| fcp_count                     | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| fcp_count                     | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| fcp_count                     | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | inp_overlap_blocking_time_ms                 | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| inp_overlap_blocking_time_ms  | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| inp_overlap_blocking_time_ms  | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| inp_overlap_blocking_time_ms  | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | inp_overlap_count                            | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| inp_overlap_count             | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| inp_overlap_count             | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| inp_overlap_count             | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | lcp_blocking_time_ms                         | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| lcp_blocking_time_ms          | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| lcp_blocking_time_ms          | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| lcp_blocking_time_ms          | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | lcp_count                                    | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| lcp_count                     | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| lcp_count                     | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| lcp_count                     | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | loading_time_blocking_time_ms                | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| loading_time_blocking_time_ms | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| loading_time_blocking_time_ms | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| loading_time_blocking_time_ms | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | loading_time_count                           | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| loading_time_count            | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| loading_time_count            | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| loading_time_count            | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | total_blocking_time_ms                       | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| total_blocking_time_ms        | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| total_blocking_time_ms        | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| total_blocking_time_ms        | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | total_count                                  | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| total_count                   | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| total_count                   | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| total_count                   | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| long_tasks_by_invoker_type    | top_invokers [*required*]               | [object] | Top invokers within this invoker type, sorted by impact score descending.                                                                                                    |
| top_invokers                  | criteria_view_occurrences                    | int32    | Number of sampled views where this invoker had long tasks contributing to the criteria metric.                                                                               |
| top_invokers                  | file [*required*]                       | string   | Cleaned source file path for the invoker script.                                                                                                                             |
| top_invokers                  | impact_score                                 | double   | Rank-product impact score combining view frequency and blocking time severity.                                                                                               |
| top_invokers                  | invoker [*required*]                    | string   | Name of the invoker function or script.                                                                                                                                      |
| top_invokers                  | stats_per_view [*required*]             | object   | Statistical distributions of long task metrics computed per view across sampled views.                                                                                       |
| stats_per_view                | fcp_blocking_time_ms                         | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| fcp_blocking_time_ms          | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| fcp_blocking_time_ms          | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| fcp_blocking_time_ms          | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | fcp_count                                    | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| fcp_count                     | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| fcp_count                     | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| fcp_count                     | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | inp_overlap_blocking_time_ms                 | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| inp_overlap_blocking_time_ms  | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| inp_overlap_blocking_time_ms  | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| inp_overlap_blocking_time_ms  | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | inp_overlap_count                            | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| inp_overlap_count             | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| inp_overlap_count             | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| inp_overlap_count             | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | lcp_blocking_time_ms                         | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| lcp_blocking_time_ms          | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| lcp_blocking_time_ms          | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| lcp_blocking_time_ms          | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | lcp_count                                    | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| lcp_count                     | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| lcp_count                     | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| lcp_count                     | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | loading_time_blocking_time_ms                | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| loading_time_blocking_time_ms | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| loading_time_blocking_time_ms | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| loading_time_blocking_time_ms | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | loading_time_count                           | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| loading_time_count            | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| loading_time_count            | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| loading_time_count            | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | total_blocking_time_ms                       | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| total_blocking_time_ms        | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| total_blocking_time_ms        | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| total_blocking_time_ms        | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| stats_per_view                | total_count                                  | object   | Statistical distribution (average, min, max) of a long task metric across sampled views.                                                                                     |
| total_count                   | average [*required*]                    | double   | Average value across sampled views.                                                                                                                                          |
| total_count                   | max [*required*]                        | double   | Maximum value across sampled views.                                                                                                                                          |
| total_count                   | min [*required*]                        | double   | Minimum value across sampled views.                                                                                                                                          |
| top_invokers                  | view_occurrences [*required*]           | int32    | Number of sampled views where this invoker had any long tasks.                                                                                                               |
| long_tasks_by_invoker_type    | view_occurrences [*required*]           | int32    | Number of sampled views where this invoker type had any long tasks.                                                                                                          |
| attributes                    | sampled_view_ids [*required*]           | [string] | List of RUM view IDs sampled for this aggregation, capped at 50.                                                                                                             |
| attributes                    | to [*required*]                         | int64    | End of the analyzed time range as a Unix timestamp in seconds.                                                                                                               |
| attributes                    | view_count [*required*]                 | int32    | Number of view instances included in the analysis.                                                                                                                           |
| attributes                    | view_name [*required*]                  | string   | The RUM view name that was analyzed.                                                                                                                                         |
| data                          | id [*required*]                         | string   | Hash-based unique identifier for this aggregation.                                                                                                                           |
| data                          | type [*required*]                       | enum     | The JSON:API type for aggregated long tasks requests. Allowed enum values: `aggregated_long_tasks`                                                                           |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "application_id": "ccbc53b1-74f2-496b-bdd7-9a8fa7b7376b",
      "criteria": {
        "max": 5,
        "metric": "largest_contentful_paint",
        "min": 2.5
      },
      "from": 1762437564,
      "long_tasks_by_invoker_type": [
        {
          "criteria_view_occurrences": 40,
          "impact_score": 0.4,
          "invoker_type": "resolve-promise",
          "stats_per_view": {
            "fcp_blocking_time_ms": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "fcp_count": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "inp_overlap_blocking_time_ms": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "inp_overlap_count": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "lcp_blocking_time_ms": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "lcp_count": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "loading_time_blocking_time_ms": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "loading_time_count": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "total_blocking_time_ms": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            },
            "total_count": {
              "average": 3504.1,
              "max": 3517.8,
              "min": 3500.1
            }
          },
          "top_invokers": [
            {
              "criteria_view_occurrences": 40,
              "file": "src/pages/Gallery.tsx",
              "impact_score": 0.67,
              "invoker": "Response.json.then",
              "stats_per_view": {
                "fcp_blocking_time_ms": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "fcp_count": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "inp_overlap_blocking_time_ms": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "inp_overlap_count": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "lcp_blocking_time_ms": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "lcp_count": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "loading_time_blocking_time_ms": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "loading_time_count": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "total_blocking_time_ms": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                },
                "total_count": {
                  "average": 3504.1,
                  "max": 3517.8,
                  "min": 3500.1
                }
              },
              "view_occurrences": 68
            }
          ],
          "view_occurrences": 68
        }
      ],
      "sampled_view_ids": [
        "6fbf69b6-9455-436a-b894-a6bf64126d40"
      ],
      "to": 1762523964,
      "view_count": 50,
      "view_name": "/account/login(/:type)"
    },
    "id": "2f0b3455",
    "type": "aggregated_long_tasks"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="401" %}
Unauthorized
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/rum/query/insight/aggregated_long_tasks" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "application_id": "ccbc53b1-74f2-496b-bdd7-9a8fa7b7376b",
      "from": 1762437564,
      "sample_size": 20,
      "to": 1762523964,
      "view_name": "/account/login(/:type)"
    },
    "type": "aggregated_long_tasks"
  }
}
EOF 
                
{% /tab %}
