---
title: Get SPA recommendations v2
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Spa
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Get SPA recommendations v2{% #get-spa-recommendations-v2 %}

{% tab title="v2" %}
**Note**: This endpoint is in preview and may change in the future. It is not yet recommended for production use.
| Datadog site      | API endpoint                                                               |
| ----------------- | -------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/spa/recommendations-v2/{service} |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/spa/recommendations-v2/{service} |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/spa/recommendations-v2/{service}      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/spa/recommendations-v2/{service}      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/spa/recommendations-v2/{service}  |
| uk1.datadoghq.com | POST https://api.uk1.datadoghq.com/api/v2/spa/recommendations-v2/{service} |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/spa/recommendations-v2/{service}     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/spa/recommendations-v2/{service} |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/spa/recommendations-v2/{service} |

### Overview

This endpoint is experimental and restricted to Datadog internal use only. Retrieve resource recommendations for a Spark job. The caller (Spark Gateway) provides a service name and the job's raw arguments. SPA determines which arguments are relevant for the service and returns structured recommendations for driver and executor resources.

### Arguments

#### Path Parameters

| Name                      | Type   | Description                      |
| ------------------------- | ------ | -------------------------------- |
| service [*required*] | string | The service name for a Spark job |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type     | Description                                                                                                                                      |
| ------------ | ---------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|              | data [*required*]       | object   | JSON:API resource object for the SPA v2 recommendation request.                                                                                  |
| data         | attributes [*required*] | object   | Attributes for requesting SPA recommendations by forwarding a Spark job's raw arguments instead of a pre-computed shard.                         |
| attributes   | arguments [*required*]  | [string] | Raw, unfiltered Spark job arguments as submitted (for example, `--org_id=2`). SPA determines which arguments are relevant for the given service. |
| data         | type [*required*]       | enum     | JSON:API resource type for the SPA v2 recommendation request. Allowed enum values: `recommendation_v2_request`                                   |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "arguments": [
        ""
      ]
    },
    "type": "recommendation_v2_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}

| Parent field | Field                        | Type   | Description                                                                                                                                                                                                             |
| ------------ | ---------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object | JSON:API resource object for SPA Recommendation. Includes type, optional ID, and resource attributes with structured recommendations.                                                                                   |
| data         | attributes [*required*] | object | Attributes of the SPA Recommendation resource. Contains recommendations for both driver and executor components.                                                                                                        |
| attributes   | confidence_level             | double | The confidence level of the recommendation, expressed as a value between 0.0 (low confidence) and 1.0 (high confidence).                                                                                                |
| attributes   | driver [*required*]     | object | Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs.                                                                                      |
| driver       | estimation [*required*] | object | Recommended resource values for a Spark driver or executor, derived from recent real usage metrics. Used by SPA to propose more efficient pod sizing.                                                                   |
| estimation   | cpu                          | object | CPU usage statistics derived from historical Spark job metrics. Provides multiple estimates so users can choose between conservative and cost-saving risk profiles.                                                     |
| cpu          | max                          | int64  | Maximum CPU usage observed for the job, expressed in millicores. This represents the upper bound of usage.                                                                                                              |
| cpu          | p75                          | int64  | 75th percentile of CPU usage (millicores). Represents a cost-saving configuration while covering most workloads.                                                                                                        |
| cpu          | p95                          | int64  | 95th percentile of CPU usage (millicores). Balances performance and cost, providing a safer margin than p75.                                                                                                            |
| estimation   | ephemeral_storage            | int64  | Recommended ephemeral storage allocation (in MiB). Derived from job temporary storage patterns.                                                                                                                         |
| estimation   | heap                         | int64  | Recommended JVM heap size (in MiB).                                                                                                                                                                                     |
| estimation   | memory                       | int64  | Recommended total memory allocation (in MiB). Includes both heap and overhead.                                                                                                                                          |
| estimation   | overhead                     | int64  | Recommended JVM overhead (in MiB). Computed as total memory - heap.                                                                                                                                                     |
| attributes   | executor [*required*]   | object | Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs.                                                                                      |
| executor     | estimation [*required*] | object | Recommended resource values for a Spark driver or executor, derived from recent real usage metrics. Used by SPA to propose more efficient pod sizing.                                                                   |
| estimation   | cpu                          | object | CPU usage statistics derived from historical Spark job metrics. Provides multiple estimates so users can choose between conservative and cost-saving risk profiles.                                                     |
| cpu          | max                          | int64  | Maximum CPU usage observed for the job, expressed in millicores. This represents the upper bound of usage.                                                                                                              |
| cpu          | p75                          | int64  | 75th percentile of CPU usage (millicores). Represents a cost-saving configuration while covering most workloads.                                                                                                        |
| cpu          | p95                          | int64  | 95th percentile of CPU usage (millicores). Balances performance and cost, providing a safer margin than p75.                                                                                                            |
| estimation   | ephemeral_storage            | int64  | Recommended ephemeral storage allocation (in MiB). Derived from job temporary storage patterns.                                                                                                                         |
| estimation   | heap                         | int64  | Recommended JVM heap size (in MiB).                                                                                                                                                                                     |
| estimation   | memory                       | int64  | Recommended total memory allocation (in MiB). Includes both heap and overhead.                                                                                                                                          |
| estimation   | overhead                     | int64  | Recommended JVM overhead (in MiB). Computed as total memory - heap.                                                                                                                                                     |
| attributes   | matched_params               | string | Only returned by the v2 endpoint. The job parameters whose values the recommendation was matched on, as `parameter=value` pairs joined by `|`. An empty string means the service-wide (coarse) recommendation was used. |
| data         | id                           | string | Resource identifier for the recommendation. Optional in responses.                                                                                                                                                      |
| data         | type [*required*]       | enum   | JSON:API resource type for Spark Pod Autosizing recommendations. Identifies the Recommendation resource returned by SPA. Allowed enum values: `recommendation`                                                          |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "confidence_level": "number",
      "driver": {
        "estimation": {
          "cpu": {
            "max": "integer",
            "p75": "integer",
            "p95": "integer"
          },
          "ephemeral_storage": "integer",
          "heap": "integer",
          "memory": "integer",
          "overhead": "integer"
        }
      },
      "executor": {
        "estimation": {
          "cpu": {
            "max": "integer",
            "p75": "integer",
            "p95": "integer"
          },
          "ephemeral_storage": "integer",
          "heap": "integer",
          "memory": "integer",
          "overhead": "integer"
        }
      },
      "matched_params": "detailed_metrics=false|Region=US1"
    },
    "id": "string",
    "type": "recommendation"
  }
}
```

{% /tab %}

{% tab title="Model" %}
JSON:API document containing a single Recommendation resource. Returned by SPA when the Spark Gateway requests recommendations.

| Parent field | Field                        | Type   | Description                                                                                                                                                                                                             |
| ------------ | ---------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object | JSON:API resource object for SPA Recommendation. Includes type, optional ID, and resource attributes with structured recommendations.                                                                                   |
| data         | attributes [*required*] | object | Attributes of the SPA Recommendation resource. Contains recommendations for both driver and executor components.                                                                                                        |
| attributes   | confidence_level             | double | The confidence level of the recommendation, expressed as a value between 0.0 (low confidence) and 1.0 (high confidence).                                                                                                |
| attributes   | driver [*required*]     | object | Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs.                                                                                      |
| driver       | estimation [*required*] | object | Recommended resource values for a Spark driver or executor, derived from recent real usage metrics. Used by SPA to propose more efficient pod sizing.                                                                   |
| estimation   | cpu                          | object | CPU usage statistics derived from historical Spark job metrics. Provides multiple estimates so users can choose between conservative and cost-saving risk profiles.                                                     |
| cpu          | max                          | int64  | Maximum CPU usage observed for the job, expressed in millicores. This represents the upper bound of usage.                                                                                                              |
| cpu          | p75                          | int64  | 75th percentile of CPU usage (millicores). Represents a cost-saving configuration while covering most workloads.                                                                                                        |
| cpu          | p95                          | int64  | 95th percentile of CPU usage (millicores). Balances performance and cost, providing a safer margin than p75.                                                                                                            |
| estimation   | ephemeral_storage            | int64  | Recommended ephemeral storage allocation (in MiB). Derived from job temporary storage patterns.                                                                                                                         |
| estimation   | heap                         | int64  | Recommended JVM heap size (in MiB).                                                                                                                                                                                     |
| estimation   | memory                       | int64  | Recommended total memory allocation (in MiB). Includes both heap and overhead.                                                                                                                                          |
| estimation   | overhead                     | int64  | Recommended JVM overhead (in MiB). Computed as total memory - heap.                                                                                                                                                     |
| attributes   | executor [*required*]   | object | Resource recommendation for a single Spark component (driver or executor). Contains estimation data used to patch Spark job specs.                                                                                      |
| executor     | estimation [*required*] | object | Recommended resource values for a Spark driver or executor, derived from recent real usage metrics. Used by SPA to propose more efficient pod sizing.                                                                   |
| estimation   | cpu                          | object | CPU usage statistics derived from historical Spark job metrics. Provides multiple estimates so users can choose between conservative and cost-saving risk profiles.                                                     |
| cpu          | max                          | int64  | Maximum CPU usage observed for the job, expressed in millicores. This represents the upper bound of usage.                                                                                                              |
| cpu          | p75                          | int64  | 75th percentile of CPU usage (millicores). Represents a cost-saving configuration while covering most workloads.                                                                                                        |
| cpu          | p95                          | int64  | 95th percentile of CPU usage (millicores). Balances performance and cost, providing a safer margin than p75.                                                                                                            |
| estimation   | ephemeral_storage            | int64  | Recommended ephemeral storage allocation (in MiB). Derived from job temporary storage patterns.                                                                                                                         |
| estimation   | heap                         | int64  | Recommended JVM heap size (in MiB).                                                                                                                                                                                     |
| estimation   | memory                       | int64  | Recommended total memory allocation (in MiB). Includes both heap and overhead.                                                                                                                                          |
| estimation   | overhead                     | int64  | Recommended JVM overhead (in MiB). Computed as total memory - heap.                                                                                                                                                     |
| attributes   | matched_params               | string | Only returned by the v2 endpoint. The job parameters whose values the recommendation was matched on, as `parameter=value` pairs joined by `|`. An empty string means the service-wide (coarse) recommendation was used. |
| data         | id                           | string | Resource identifier for the recommendation. Optional in responses.                                                                                                                                                      |
| data         | type [*required*]       | enum   | JSON:API resource type for Spark Pod Autosizing recommendations. Identifies the Recommendation resource returned by SPA. Allowed enum values: `recommendation`                                                          |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "confidence_level": "number",
      "driver": {
        "estimation": {
          "cpu": {
            "max": "integer",
            "p75": "integer",
            "p95": "integer"
          },
          "ephemeral_storage": "integer",
          "heap": "integer",
          "memory": "integer",
          "overhead": "integer"
        }
      },
      "executor": {
        "estimation": {
          "cpu": {
            "max": "integer",
            "p75": "integer",
            "p95": "integer"
          },
          "ephemeral_storage": "integer",
          "heap": "integer",
          "memory": "integer",
          "overhead": "integer"
        }
      },
      "matched_params": "detailed_metrics=false|Region=US1"
    },
    "id": "string",
    "type": "recommendation"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% 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 %}

{% tab title="403" %}
Not Authorized
{% 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 %}

{% tab title="404" %}
Not Found
{% 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 %}

{% 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

##### 
                  \# Path parameters export service="CHANGE_ME" \# Use a Personal Access Token or Service Access Token export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"  \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/spa/recommendations-v2/${service}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "arguments": [
        ""
      ]
    },
    "type": "recommendation_v2_request"
  }
}
EOF 
                
##### 

```python
"""
Get SPA recommendations v2 returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.spa_api import SpaApi
from datadog_api_client.v2.model.recommendation_v2_request_attributes import RecommendationV2RequestAttributes
from datadog_api_client.v2.model.recommendation_v2_request_body import RecommendationV2RequestBody
from datadog_api_client.v2.model.recommendation_v2_request_data import RecommendationV2RequestData
from datadog_api_client.v2.model.recommendation_v2_request_type import RecommendationV2RequestType

body = RecommendationV2RequestBody(
    data=RecommendationV2RequestData(
        attributes=RecommendationV2RequestAttributes(
            arguments=[
                "",
            ],
        ),
        type=RecommendationV2RequestType.RECOMMENDATION_V2_REQUEST,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["get_spa_recommendations_v2"] = True
with ApiClient(configuration) as api_client:
    api_instance = SpaApi(api_client)
    response = api_instance.get_spa_recommendations_v2(service="service", body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
##### 

```ruby
# Get SPA recommendations v2 returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
  config.unstable_operations["v2.get_spa_recommendations_v2".to_sym] = true
end
api_instance = DatadogAPIClient::V2::SpaAPI.new

body = DatadogAPIClient::V2::RecommendationV2RequestBody.new({
  data: DatadogAPIClient::V2::RecommendationV2RequestData.new({
    attributes: DatadogAPIClient::V2::RecommendationV2RequestAttributes.new({
      arguments: [
        "",
      ],
    }),
    type: DatadogAPIClient::V2::RecommendationV2RequestType::RECOMMENDATION_V2_REQUEST,
  }),
})
p api_instance.get_spa_recommendations_v2("service", body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
##### 

```go
// Get SPA recommendations v2 returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.RecommendationV2RequestBody{
		Data: datadogV2.RecommendationV2RequestData{
			Attributes: datadogV2.RecommendationV2RequestAttributes{
				Arguments: []string{
					"",
				},
			},
			Type: datadogV2.RECOMMENDATIONV2REQUESTTYPE_RECOMMENDATION_V2_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.GetSPARecommendationsV2", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewSpaApi(apiClient)
	resp, r, err := api.GetSPARecommendationsV2(ctx, "service", body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `SpaApi.GetSPARecommendationsV2`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SpaApi.GetSPARecommendationsV2`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
##### 

```java
// Get SPA recommendations v2 returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SpaApi;
import com.datadog.api.client.v2.model.RecommendationDocument;
import com.datadog.api.client.v2.model.RecommendationV2RequestAttributes;
import com.datadog.api.client.v2.model.RecommendationV2RequestBody;
import com.datadog.api.client.v2.model.RecommendationV2RequestData;
import com.datadog.api.client.v2.model.RecommendationV2RequestType;
import java.util.Collections;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    defaultClient.setUnstableOperationEnabled("v2.getSPARecommendationsV2", true);
    SpaApi apiInstance = new SpaApi(defaultClient);

    RecommendationV2RequestBody body =
        new RecommendationV2RequestBody()
            .data(
                new RecommendationV2RequestData()
                    .attributes(
                        new RecommendationV2RequestAttributes()
                            .arguments(Collections.singletonList("")))
                    .type(RecommendationV2RequestType.RECOMMENDATION_V2_REQUEST));

    try {
      RecommendationDocument result = apiInstance.getSPARecommendationsV2("service", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SpaApi#getSPARecommendationsV2");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
##### 

```rust
// Get SPA recommendations v2 returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_spa::SpaAPI;
use datadog_api_client::datadogV2::model::RecommendationV2RequestAttributes;
use datadog_api_client::datadogV2::model::RecommendationV2RequestBody;
use datadog_api_client::datadogV2::model::RecommendationV2RequestData;
use datadog_api_client::datadogV2::model::RecommendationV2RequestType;

#[tokio::main]
async fn main() {
    let body = RecommendationV2RequestBody::new(RecommendationV2RequestData::new(
        RecommendationV2RequestAttributes::new(vec!["".to_string()]),
        RecommendationV2RequestType::RECOMMENDATION_V2_REQUEST,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.get_spa_recommendations_v2", true);
    let api = SpaAPI::with_config(configuration);
    let resp = api
        .get_spa_recommendations_v2("service".to_string(), body)
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" cargo run
{% /tab %}
