Skip to content

Commit dc8638d

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
and
ci.datadog-api-spec
authored
Add Formula and Function query support to heatmap widgets (#1319)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent f6fedee commit dc8638d

File tree

7 files changed

+229
-4
lines changed

7 files changed

+229
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.5",
7-
"regenerated": "2023-09-12 20:28:17.290809",
8-
"spec_repo_commit": "bc2ae18f"
7+
"regenerated": "2023-09-13 14:37:15.420184",
8+
"spec_repo_commit": "ec46249d"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.5",
12-
"regenerated": "2023-09-12 20:28:17.303876",
13-
"spec_repo_commit": "bc2ae18f"
12+
"regenerated": "2023-09-13 14:37:15.436584",
13+
"spec_repo_commit": "ec46249d"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,6 +3422,11 @@ components:
34223422
$ref: '#/components/schemas/LogQueryDefinition'
34233423
event_query:
34243424
$ref: '#/components/schemas/EventQueryDefinition'
3425+
formulas:
3426+
description: List of formulas that operate on queries.
3427+
items:
3428+
$ref: '#/components/schemas/WidgetFormula'
3429+
type: array
34253430
log_query:
34263431
$ref: '#/components/schemas/LogQueryDefinition'
34273432
network_query:
@@ -3433,6 +3438,13 @@ components:
34333438
q:
34343439
description: Widget query.
34353440
type: string
3441+
queries:
3442+
description: List of queries that can be returned directly or used in formulas.
3443+
items:
3444+
$ref: '#/components/schemas/FormulaAndFunctionQueryDefinition'
3445+
type: array
3446+
response_format:
3447+
$ref: '#/components/schemas/FormulaAndFunctionResponseFormat'
34363448
rum_query:
34373449
$ref: '#/components/schemas/LogQueryDefinition'
34383450
security_query:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-09-12T19:51:40.932Z"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with formula and function heatmap widget",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "2c3b89238cc7caa5503006df123a1604",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 527,
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": "{\"is_read_only\":false,\"layout_type\":\"free\",\"notify_list\":[],\"template_variables\":[],\"title\":\"Test-Create_a_new_dashboard_with_formula_and_function_heatmap_widget-1694548300\",\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\"}],\"response_format\":\"timeseries\",\"style\":{\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"heatmap\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 864,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 864,
45+
"text": "{\"id\":\"agm-reh-km8\",\"title\":\"Test-Create_a_new_dashboard_with_formula_and_function_heatmap_widget-1694548300\",\"description\":null,\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"free\",\"url\":\"/dashboard/agm-reh-km8/test-createanewdashboardwithformulaandfunctionheatmapwidget-1694548300\",\"is_read_only\":false,\"template_variables\":[],\"widgets\":[{\"definition\":{\"requests\":[{\"formulas\":[{\"formula\":\"query1\"}],\"queries\":[{\"data_source\":\"metrics\",\"name\":\"query1\",\"query\":\"avg:system.cpu.user{*}\"}],\"response_format\":\"timeseries\",\"style\":{\"palette\":\"dog_classic\"}}],\"time\":{},\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"heatmap\"},\"layout\":{\"height\":15,\"width\":47,\"x\":0,\"y\":0},\"id\":658874190518028}],\"notify_list\":[],\"created_at\":\"2023-09-12T19:51:41.163760+00:00\",\"modified_at\":\"2023-09-12T19:51:41.163760+00:00\",\"restricted_roles\":[]}\n"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 517,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2023-09-12T19:51:40.940Z",
61+
"time": 290
62+
},
63+
{
64+
"_id": "80d084303632271b710c1e318ec66d25",
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/agm-reh-km8"
82+
},
83+
"response": {
84+
"bodySize": 39,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 39,
88+
"text": "{\"deleted_dashboard_id\":\"agm-reh-km8\"}\n"
89+
},
90+
"cookies": [],
91+
"headers": [
92+
{
93+
"name": "content-type",
94+
"value": "application/json"
95+
}
96+
],
97+
"headersSize": 516,
98+
"httpVersion": "HTTP/1.1",
99+
"redirectURL": "",
100+
"status": 200,
101+
"statusText": "OK"
102+
},
103+
"startedDateTime": "2023-09-12T19:51:41.256Z",
104+
"time": 192
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Create a new dashboard with formula and function heatmap widget
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+
title: "Example-Dashboard",
13+
widgets: [
14+
{
15+
layout: {
16+
x: 0,
17+
y: 0,
18+
width: 47,
19+
height: 15,
20+
},
21+
definition: {
22+
title: "",
23+
titleSize: "16",
24+
titleAlign: "left",
25+
time: {},
26+
type: "heatmap",
27+
requests: [
28+
{
29+
responseFormat: "timeseries",
30+
queries: [
31+
{
32+
dataSource: "metrics",
33+
name: "query1",
34+
query: "avg:system.cpu.user{*}",
35+
},
36+
],
37+
formulas: [
38+
{
39+
formula: "query1",
40+
},
41+
],
42+
style: {
43+
palette: "dog_classic",
44+
},
45+
},
46+
],
47+
},
48+
},
49+
],
50+
templateVariables: [],
51+
layoutType: "free",
52+
isReadOnly: false,
53+
notifyList: [],
54+
},
55+
};
56+
57+
apiInstance
58+
.createDashboard(params)
59+
.then((data: v1.Dashboard) => {
60+
console.log(
61+
"API called successfully. Returned data: " + JSON.stringify(data)
62+
);
63+
})
64+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,17 @@ Feature: Dashboards
324324
And the response "widgets[0].definition.type" is equal to "event_timeline"
325325
And the response "widgets[0].definition.query" is equal to "status:error priority:all"
326326

327+
@team:DataDog/dashboards-backend
328+
Scenario: Create a new dashboard with formula and function heatmap widget
329+
Given new "CreateDashboard" request
330+
And body with value {"title": "{{ unique }}", "widgets": [{"layout": {"x": 0, "y": 0, "width": 47, "height": 15}, "definition": {"title": "", "title_size": "16", "title_align": "left", "time": {}, "type": "heatmap", "requests": [{"response_format": "timeseries", "queries": [{"data_source": "metrics", "name": "query1", "query": "avg:system.cpu.user{*}"}], "formulas": [{"formula": "query1"}], "style": {"palette": "dog_classic"}}]}}], "template_variables": [], "layout_type": "free", "is_read_only": false, "notify_list": []}
331+
When the request is sent
332+
Then the response status is 200 OK
333+
And the response "widgets[0].definition.type" is equal to "heatmap"
334+
And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "avg:system.cpu.user{*}"
335+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "metrics"
336+
And the response "widgets[0].definition.requests[0].style.palette" is equal to "dog_classic"
337+
327338
@team:DataDog/dashboards-backend
328339
Scenario: Create a new dashboard with formulas and functions scatterplot widget
329340
Given new "CreateDashboard" request

packages/datadog-api-client-v1/models/HeatMapWidgetRequest.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44
* Copyright 2020-Present Datadog, Inc.
55
*/
66
import { EventQueryDefinition } from "./EventQueryDefinition";
7+
import { FormulaAndFunctionQueryDefinition } from "./FormulaAndFunctionQueryDefinition";
8+
import { FormulaAndFunctionResponseFormat } from "./FormulaAndFunctionResponseFormat";
79
import { LogQueryDefinition } from "./LogQueryDefinition";
810
import { ProcessQueryDefinition } from "./ProcessQueryDefinition";
11+
import { WidgetFormula } from "./WidgetFormula";
912
import { WidgetStyle } from "./WidgetStyle";
1013

1114
import { AttributeTypeMap } from "../../datadog-api-client-common/util";
@@ -22,6 +25,10 @@ export class HeatMapWidgetRequest {
2225
* The event query.
2326
*/
2427
"eventQuery"?: EventQueryDefinition;
28+
/**
29+
* List of formulas that operate on queries.
30+
*/
31+
"formulas"?: Array<WidgetFormula>;
2532
/**
2633
* The log query.
2734
*/
@@ -42,6 +49,14 @@ export class HeatMapWidgetRequest {
4249
* Widget query.
4350
*/
4451
"q"?: string;
52+
/**
53+
* List of queries that can be returned directly or used in formulas.
54+
*/
55+
"queries"?: Array<FormulaAndFunctionQueryDefinition>;
56+
/**
57+
* Timeseries, scalar, or event list response. Event list response formats are supported by Geomap widgets.
58+
*/
59+
"responseFormat"?: FormulaAndFunctionResponseFormat;
4560
/**
4661
* The log query.
4762
*/
@@ -72,6 +87,10 @@ export class HeatMapWidgetRequest {
7287
baseName: "event_query",
7388
type: "EventQueryDefinition",
7489
},
90+
formulas: {
91+
baseName: "formulas",
92+
type: "Array<WidgetFormula>",
93+
},
7594
logQuery: {
7695
baseName: "log_query",
7796
type: "LogQueryDefinition",
@@ -92,6 +111,14 @@ export class HeatMapWidgetRequest {
92111
baseName: "q",
93112
type: "string",
94113
},
114+
queries: {
115+
baseName: "queries",
116+
type: "Array<FormulaAndFunctionQueryDefinition>",
117+
},
118+
responseFormat: {
119+
baseName: "response_format",
120+
type: "FormulaAndFunctionResponseFormat",
121+
},
95122
rumQuery: {
96123
baseName: "rum_query",
97124
type: "LogQueryDefinition",

0 commit comments

Comments
 (0)