Skip to content

Commit 6770461

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

File tree

18 files changed

+325
-0
lines changed

18 files changed

+325
-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+
}

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

services/dashboards/src/v1/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export { FormulaAndFunctionEventsDataSource } from "./models/FormulaAndFunctionE
7878
export { FormulaAndFunctionMetricAggregation } from "./models/FormulaAndFunctionMetricAggregation";
7979
export { FormulaAndFunctionMetricDataSource } from "./models/FormulaAndFunctionMetricDataSource";
8080
export { FormulaAndFunctionMetricQueryDefinition } from "./models/FormulaAndFunctionMetricQueryDefinition";
81+
export { FormulaAndFunctionMetricSemanticMode } from "./models/FormulaAndFunctionMetricSemanticMode";
8182
export { FormulaAndFunctionProcessQueryDataSource } from "./models/FormulaAndFunctionProcessQueryDataSource";
8283
export { FormulaAndFunctionProcessQueryDefinition } from "./models/FormulaAndFunctionProcessQueryDefinition";
8384
export { FormulaAndFunctionQueryDefinition } from "./models/FormulaAndFunctionQueryDefinition";

services/dashboards/src/v1/models/FormulaAndFunctionMetricQueryDefinition.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AttributeTypeMap } from "@datadog/datadog-api-client";
22

33
import { FormulaAndFunctionMetricAggregation } from "./FormulaAndFunctionMetricAggregation";
44
import { FormulaAndFunctionMetricDataSource } from "./FormulaAndFunctionMetricDataSource";
5+
import { FormulaAndFunctionMetricSemanticMode } from "./FormulaAndFunctionMetricSemanticMode";
56

67
/**
78
* A formula and functions metrics query.
@@ -27,6 +28,10 @@ export class FormulaAndFunctionMetricQueryDefinition {
2728
* Metrics query definition.
2829
*/
2930
"query": string;
31+
/**
32+
* Semantic mode for metrics queries. This determines how metrics from different sources are combined or displayed.
33+
*/
34+
"semanticMode"?: FormulaAndFunctionMetricSemanticMode;
3035
/**
3136
* A container for additional, undeclared properties.
3237
* This is a holder for any undeclared properties as specified with
@@ -65,6 +70,10 @@ export class FormulaAndFunctionMetricQueryDefinition {
6570
type: "string",
6671
required: true,
6772
},
73+
semanticMode: {
74+
baseName: "semantic_mode",
75+
type: "FormulaAndFunctionMetricSemanticMode",
76+
},
6877
additionalProperties: {
6978
baseName: "additionalProperties",
7079
type: "{ [key: string]: any; }",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { UnparsedObject } from "@datadog/datadog-api-client";
2+
3+
/**
4+
* Semantic mode for metrics queries. This determines how metrics from different sources are combined or displayed.
5+
*/
6+
export type FormulaAndFunctionMetricSemanticMode =
7+
| typeof COMBINED
8+
| typeof NATIVE
9+
| UnparsedObject;
10+
export const COMBINED = "combined";
11+
export const NATIVE = "native";

services/dashboards/src/v1/models/TypingInfo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ export const TypingInfo: ModelTypingInfo = {
248248
"percentile",
249249
],
250250
FormulaAndFunctionMetricDataSource: ["metrics"],
251+
FormulaAndFunctionMetricSemanticMode: ["combined", "native"],
251252
FormulaAndFunctionProcessQueryDataSource: ["process", "container"],
252253
FormulaAndFunctionResponseFormat: ["timeseries", "scalar", "event_list"],
253254
FormulaAndFunctionSLODataSource: ["slo"],

0 commit comments

Comments
 (0)