JSON:API resource containing the cost recommendations filter. This legacy search contract
uses the resource ID for the filter expression rather than as a persistent resource identifier.
attributes
object
Attributes used to filter and sort cost recommendations.
filter
string
Filter expression applied to the recommendations. When supplied, this attribute overrides
data.id, including when empty. When omitted, data.id is used. If the resulting filter
is empty, it defaults to *. Scope, view, and pagination still apply.
scope
enum
Recommendations scope. Defaults to ccm; use experiment for experimental recommendations or * for both.
Allowed enum values: ccm,experiment,*
sort
[object]
Ordered list of sort clauses applied to the result set.
expression
string
Field to sort by (for example, @potential_daily_savings).
order
string
Sort direction, either ASC or DESC.
view
string
Active view name (for example, active, dismissed, open, in-progress, or completed).
id
string
Filter expression applied to the recommendations when attributes.filter is omitted.
When supplied, attributes.filter overrides this value, including when empty. If the
resulting filter is empty, it defaults to *. Scope, view, and pagination still apply.
type [required]
enum
Legacy JSON:API resource type required by the cost recommendations search decoder.
Allowed enum values: recommendations_filter
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"python3"example.py"
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"rb"example.rb"
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"java"Example.java"
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_API_KEY="<DD_API_KEY>"DD_APP_KEY="<DD_APP_KEY>"cargo run
/**
* Search cost recommendations returns "OK" response
*/import{client,v2}from"@datadog/datadog-api-client";constconfiguration=client.createConfiguration({authMethods:{AuthZ:{accessToken: process.env.DD_BEARER_TOKENasstring,},},});configuration.unstableOperations["v2.searchCostRecommendations"]=true;constapiInstance=newv2.CloudCostManagementApi(configuration);constparams: v2.CloudCostManagementApiSearchCostRecommendationsRequest={body:{data:{attributes:{scope:"ccm",sort:[{expression:"potential_daily_savings.amount",order:"DESC",},],},id:"@resource_table:aws_ec2_instance",type:"recommendations_filter",},},};apiInstance.searchCostRecommendations(params).then((data: v2.CostRecommendationArray)=>{console.log("API called successfully. Returned data: "+JSON.stringify(data));}).catch((error: any)=>console.error(error));
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"tsc"example.ts"
// Search cost recommendations returns "OK" responsepackagemainimport("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")funcmain(){body:=datadogV2.RecommendationsFilterRequest{Data:datadogV2.RecommendationsFilterRequestData{Attributes:&datadogV2.RecommendationsFilterRequestDataAttributes{Scope:datadogV2.RECOMMENDATIONSFILTERREQUESTSCOPE_CCM.Ptr(),Sort:[]datadogV2.RecommendationsFilterRequestSortItems{{Expression:datadog.PtrString("@potential_daily_savings"),Order:datadog.PtrString("DESC"),},},},Id:datadog.PtrString("@resource_table:aws_ec2_instance"),Type:datadogV2.RECOMMENDATIONSFILTERREQUESTDATATYPE_RECOMMENDATIONS_FILTER,},}ctx:=datadog.NewDefaultContext(context.Background())ctx=context.WithValue(ctx,datadog.ContextAccessToken,os.Getenv("DD_BEARER_TOKEN"))configuration:=datadog.NewConfiguration()configuration.SetUnstableOperationEnabled("v2.SearchCostRecommendations",true)apiClient:=datadog.NewAPIClient(configuration)api:=datadogV2.NewCloudCostManagementApi(apiClient)resp,r,err:=api.SearchCostRecommendations(ctx,body,*datadogV2.NewSearchCostRecommendationsOptionalParameters())iferr!=nil{fmt.Fprintf(os.Stderr,"Error when calling `CloudCostManagementApi.SearchCostRecommendations`: %v\n",err)fmt.Fprintf(os.Stderr,"Full HTTP response: %v\n",r)}responseContent,_:=json.MarshalIndent(resp,""," ")fmt.Fprintf(os.Stdout,"Response from `CloudCostManagementApi.SearchCostRecommendations`:\n%s\n",responseContent)}
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comuk1.datadoghq.comddog-gov.comus2.ddog-gov.com"DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"go run"main.go"
Request a personalized demo
Get Started with Datadog
Ask AI
AI-generated responses may be inaccurate. Verify important info.