Skip to content

Commit 0270993

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Dashboards - Add semantic_mode support to FormulaAndFunctionMetricQueryDefinition (#3088)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 231c215 commit 0270993

File tree

12 files changed

+388
-0
lines changed

12 files changed

+388
-0
lines changed

.generator/schemas/v1/openapi.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2952,11 +2952,24 @@ components:
29522952
description: Metrics query definition.
29532953
example: avg:system.cpu.user{*}
29542954
type: string
2955+
semantic_mode:
2956+
$ref: '#/components/schemas/FormulaAndFunctionMetricSemanticMode'
29552957
required:
29562958
- data_source
29572959
- query
29582960
- name
29592961
type: object
2962+
FormulaAndFunctionMetricSemanticMode:
2963+
description: Semantic mode for metrics queries. This determines how metrics
2964+
from different sources are combined or displayed.
2965+
enum:
2966+
- combined
2967+
- native
2968+
example: combined
2969+
type: string
2970+
x-enum-varnames:
2971+
- COMBINED
2972+
- NATIVE
29602973
FormulaAndFunctionProcessQueryDataSource:
29612974
description: Data sources that rely on the process backend.
29622975
enum:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2025-12-08T18:40:10.047Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with a timeseries widget using formulas and functions metrics query with combined semantic_mode",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "12799a148e003af063c668a7afe8dc6f",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 445,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 559,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_metrics_query_with_comb-1765219210 with combined semantic_mode\",\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\",\"semantic_mode\":\"combined\"}],\"response_format\":\"timeseries\"}],\"type\":\"timeseries\"}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 839,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 839,
45+
"text": "{\"id\":\"bpt-wdw-b9x\",\"title\":\"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_metrics_query_with_comb-1765219210 with combined semantic_mode\",\"description\":null,\"author_handle\":\"[email protected]\",\"author_name\":\"frog\",\"layout_type\":\"ordered\",\"url\":\"/dashboard/bpt-wdw-b9x/test-createanewdashboardwithatimeserieswidgetusingformulasandfunctionsmetricsque\",\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\",\"semantic_mode\":\"combined\"}],\"response_format\":\"timeseries\"}],\"type\":\"timeseries\"},\"id\":7196642548461969}],\"notify_list\":null,\"created_at\":\"2025-12-08T18:40:10.214467+00:00\",\"modified_at\":\"2025-12-08T18:40:10.214467+00:00\",\"restricted_roles\":[]}"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 380,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2025-12-08T18:40:10.050Z",
61+
"time": 174
62+
},
63+
{
64+
"_id": "9b44312ffbef89fa47c293c7e4a76bde",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 520,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/dashboard/bpt-wdw-b9x"
82+
},
83+
"response": {
84+
"bodySize": 38,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 38,
88+
"text": "{\"deleted_dashboard_id\":\"bpt-wdw-b9x\"}"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 379,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2025-12-08T18:40:10.230Z",
104+
"time": 354
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2025-12-08T18:32:38.191Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with a timeseries widget using formulas and functions metrics query with native semantic_mode",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "ba7f467c39d187aeca02ce0e6ebe3de8",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 441,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
},
23+
{
24+
"_fromType": "array",
25+
"name": "content-type",
26+
"value": "application/json"
27+
}
28+
],
29+
"headersSize": 557,
30+
"httpVersion": "HTTP/1.1",
31+
"method": "POST",
32+
"postData": {
33+
"mimeType": "application/json",
34+
"params": [],
35+
"text": "{\"layout_type\":\"ordered\",\"title\":\"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_metrics_query_with_nati-1765218758 with native semantic_mode\",\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\",\"semantic_mode\":\"native\"}],\"response_format\":\"timeseries\"}],\"type\":\"timeseries\"}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 835,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 835,
45+
"text": "{\"id\":\"ptr-h98-jx4\",\"title\":\"Test-Create_a_new_dashboard_with_a_timeseries_widget_using_formulas_and_functions_metrics_query_with_nati-1765218758 with native semantic_mode\",\"description\":null,\"author_handle\":\"[email protected]\",\"author_name\":\"frog\",\"layout_type\":\"ordered\",\"url\":\"/dashboard/ptr-h98-jx4/test-createanewdashboardwithatimeserieswidgetusingformulasandfunctionsmetricsque\",\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"display_type\":\"line\",\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\",\"semantic_mode\":\"native\"}],\"response_format\":\"timeseries\"}],\"type\":\"timeseries\"},\"id\":7543625669678795}],\"notify_list\":null,\"created_at\":\"2025-12-08T18:32:38.359385+00:00\",\"modified_at\":\"2025-12-08T18:32:38.359385+00:00\",\"restricted_roles\":[]}"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 380,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2025-12-08T18:32:38.194Z",
61+
"time": 191
62+
},
63+
{
64+
"_id": "e052b7cf63125b650a3cc6393245f8d4",
65+
"_order": 0,
66+
"cache": {},
67+
"request": {
68+
"bodySize": 0,
69+
"cookies": [],
70+
"headers": [
71+
{
72+
"_fromType": "array",
73+
"name": "accept",
74+
"value": "application/json"
75+
}
76+
],
77+
"headersSize": 518,
78+
"httpVersion": "HTTP/1.1",
79+
"method": "DELETE",
80+
"queryString": [],
81+
"url": "https://api.datadoghq.com/api/v1/dashboard/ptr-h98-jx4"
82+
},
83+
"response": {
84+
"bodySize": 38,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 38,
88+
"text": "{\"deleted_dashboard_id\":\"ptr-h98-jx4\"}"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 379,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2025-12-08T18:32:38.390Z",
104+
"time": 453
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Create a new dashboard with a timeseries widget using formulas and functions metrics query with native semantic_mode
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.DashboardsApi(configuration);
9+
10+
const params: v1.DashboardsApiCreateDashboardRequest = {
11+
body: {
12+
layoutType: "ordered",
13+
title: "Example-Dashboard with native semantic_mode",
14+
widgets: [
15+
{
16+
definition: {
17+
type: "timeseries",
18+
requests: [
19+
{
20+
queries: [
21+
{
22+
dataSource: "metrics",
23+
name: "query1",
24+
query: "avg:system.cpu.user{*}",
25+
semanticMode: "native",
26+
},
27+
],
28+
responseFormat: "timeseries",
29+
formulas: [
30+
{
31+
formula: "query1",
32+
},
33+
],
34+
displayType: "line",
35+
},
36+
],
37+
},
38+
},
39+
],
40+
},
41+
};
42+
43+
apiInstance
44+
.createDashboard(params)
45+
.then((data: v1.Dashboard) => {
46+
console.log(
47+
"API called successfully. Returned data: " + JSON.stringify(data)
48+
);
49+
})
50+
.catch((error: any) => console.error(error));
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Create a new dashboard with a timeseries widget using formulas and functions metrics query with combined semantic_mode
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.DashboardsApi(configuration);
9+
10+
const params: v1.DashboardsApiCreateDashboardRequest = {
11+
body: {
12+
layoutType: "ordered",
13+
title: "Example-Dashboard with combined semantic_mode",
14+
widgets: [
15+
{
16+
definition: {
17+
type: "timeseries",
18+
requests: [
19+
{
20+
queries: [
21+
{
22+
dataSource: "metrics",
23+
name: "query1",
24+
query: "avg:system.cpu.user{*}",
25+
semanticMode: "combined",
26+
},
27+
],
28+
responseFormat: "timeseries",
29+
formulas: [
30+
{
31+
formula: "query1",
32+
},
33+
],
34+
displayType: "line",
35+
},
36+
],
37+
},
38+
},
39+
],
40+
},
41+
};
42+
43+
apiInstance
44+
.createDashboard(params)
45+
.then((data: v1.Dashboard) => {
46+
console.log(
47+
"API called successfully. Returned data: " + JSON.stringify(data)
48+
);
49+
})
50+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,30 @@ Feature: Dashboards
195195
And the response "widgets[0].definition.requests[0].formulas[0].formula" is equal to "query1"
196196
And the response "widgets[0].definition.time.live_span" is equal to "week_to_date"
197197

198+
@team:DataDog/dashboards-backend
199+
Scenario: Create a new dashboard with a timeseries widget using formulas and functions metrics query with combined semantic_mode
200+
Given new "CreateDashboard" request
201+
And body with value {"layout_type": "ordered", "title": "{{ unique }} with combined semantic_mode", "widgets": [{"definition": {"type": "timeseries", "requests": [{"queries": [{"data_source": "metrics", "name": "query1", "query": "avg:system.cpu.user{*}", "semantic_mode": "combined"}], "response_format": "timeseries", "formulas": [{"formula": "query1"}], "display_type": "line"}]}}]}
202+
When the request is sent
203+
Then the response status is 200 OK
204+
And the response "widgets[0].definition.requests[0].response_format" is equal to "timeseries"
205+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "metrics"
206+
And the response "widgets[0].definition.requests[0].queries[0].name" is equal to "query1"
207+
And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "avg:system.cpu.user{*}"
208+
And the response "widgets[0].definition.requests[0].queries[0].semantic_mode" is equal to "combined"
209+
210+
@team:DataDog/dashboards-backend
211+
Scenario: Create a new dashboard with a timeseries widget using formulas and functions metrics query with native semantic_mode
212+
Given new "CreateDashboard" request
213+
And body with value {"layout_type": "ordered", "title": "{{ unique }} with native semantic_mode", "widgets": [{"definition": {"type": "timeseries", "requests": [{"queries": [{"data_source": "metrics", "name": "query1", "query": "avg:system.cpu.user{*}", "semantic_mode": "native"}], "response_format": "timeseries", "formulas": [{"formula": "query1"}], "display_type": "line"}]}}]}
214+
When the request is sent
215+
Then the response status is 200 OK
216+
And the response "widgets[0].definition.requests[0].response_format" is equal to "timeseries"
217+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "metrics"
218+
And the response "widgets[0].definition.requests[0].queries[0].name" is equal to "query1"
219+
And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "avg:system.cpu.user{*}"
220+
And the response "widgets[0].definition.requests[0].queries[0].semantic_mode" is equal to "native"
221+
198222
@team:DataDog/dashboards-backend
199223
Scenario: Create a new dashboard with a toplist widget sorted by group
200224
Given new "CreateDashboard" request

packages/datadog-api-client-v1/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ export { FormulaAndFunctionEventsDataSource } from "./models/FormulaAndFunctionE
457457
export { FormulaAndFunctionMetricAggregation } from "./models/FormulaAndFunctionMetricAggregation";
458458
export { FormulaAndFunctionMetricDataSource } from "./models/FormulaAndFunctionMetricDataSource";
459459
export { FormulaAndFunctionMetricQueryDefinition } from "./models/FormulaAndFunctionMetricQueryDefinition";
460+
export { FormulaAndFunctionMetricSemanticMode } from "./models/FormulaAndFunctionMetricSemanticMode";
460461
export { FormulaAndFunctionProcessQueryDataSource } from "./models/FormulaAndFunctionProcessQueryDataSource";
461462
export { FormulaAndFunctionProcessQueryDefinition } from "./models/FormulaAndFunctionProcessQueryDefinition";
462463
export { FormulaAndFunctionQueryDefinition } from "./models/FormulaAndFunctionQueryDefinition";

0 commit comments

Comments
 (0)