Skip to content

Commit 629126b

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add apm_metrics query support to dashboard OpenAPI spec (#3706)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 0ce0d8c commit 629126b

12 files changed

Lines changed: 566 additions & 0 deletions

File tree

.generator/schemas/v1/openapi.yaml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,6 +2709,123 @@ components:
27092709
- service
27102710
- name
27112711
type: object
2712+
FormulaAndFunctionApmMetricStatName:
2713+
description: APM metric stat name.
2714+
enum:
2715+
- errors
2716+
- error_rate
2717+
- errors_per_second
2718+
- latency_avg
2719+
- latency_max
2720+
- latency_p50
2721+
- latency_p75
2722+
- latency_p90
2723+
- latency_p95
2724+
- latency_p99
2725+
- latency_p999
2726+
- latency_distribution
2727+
- hits
2728+
- hits_per_second
2729+
- total_time
2730+
- apdex
2731+
example: "hits"
2732+
type: string
2733+
x-enum-varnames:
2734+
- ERRORS
2735+
- ERROR_RATE
2736+
- ERRORS_PER_SECOND
2737+
- LATENCY_AVG
2738+
- LATENCY_MAX
2739+
- LATENCY_P50
2740+
- LATENCY_P75
2741+
- LATENCY_P90
2742+
- LATENCY_P95
2743+
- LATENCY_P99
2744+
- LATENCY_P999
2745+
- LATENCY_DISTRIBUTION
2746+
- HITS
2747+
- HITS_PER_SECOND
2748+
- TOTAL_TIME
2749+
- APDEX
2750+
FormulaAndFunctionApmMetricsDataSource:
2751+
description: Data source for APM metrics queries.
2752+
enum:
2753+
- apm_metrics
2754+
example: apm_metrics
2755+
type: string
2756+
x-enum-varnames:
2757+
- APM_METRICS
2758+
FormulaAndFunctionApmMetricsQueryDefinition:
2759+
description: A formula and functions APM metrics query.
2760+
properties:
2761+
data_source:
2762+
$ref: "#/components/schemas/FormulaAndFunctionApmMetricsDataSource"
2763+
group_by:
2764+
description: Optional fields to group the query results by.
2765+
items:
2766+
description: A field to group results by.
2767+
example: "resource_name"
2768+
type: string
2769+
type: array
2770+
name:
2771+
description: Name of this query to use in formulas.
2772+
example: "query_errors"
2773+
type: string
2774+
operation_mode:
2775+
description: Optional operation mode to aggregate across operation names.
2776+
example: "primary"
2777+
type: string
2778+
operation_name:
2779+
description: Name of operation on service. If not provided, the primary operation name is used.
2780+
example: "web.request"
2781+
type: string
2782+
peer_tags:
2783+
description: Tags to query for a specific downstream entity (peer.service, peer.db_instance, peer.s3, peer.s3.bucket, etc.).
2784+
items:
2785+
example: "peer.service:my-service"
2786+
type: string
2787+
type: array
2788+
query_filter:
2789+
description: Additional filters for the query using metrics query syntax (e.g., env, primary_tag).
2790+
example: "env:prod"
2791+
type: string
2792+
resource_hash:
2793+
description: The hash of a specific resource to filter by.
2794+
example: "abc123"
2795+
type: string
2796+
resource_name:
2797+
description: The full name of a specific resource to filter by.
2798+
example: "GET /api/v1/users"
2799+
type: string
2800+
service:
2801+
description: APM service name.
2802+
example: "web-store"
2803+
type: string
2804+
span_kind:
2805+
$ref: "#/components/schemas/FormulaAndFunctionApmMetricsSpanKind"
2806+
stat:
2807+
$ref: "#/components/schemas/FormulaAndFunctionApmMetricStatName"
2808+
required:
2809+
- data_source
2810+
- name
2811+
- stat
2812+
type: object
2813+
FormulaAndFunctionApmMetricsSpanKind:
2814+
description: Describes the relationship between the span, its parents, and its children in a trace.
2815+
enum:
2816+
- consumer
2817+
- server
2818+
- client
2819+
- producer
2820+
- internal
2821+
example: "server"
2822+
type: string
2823+
x-enum-varnames:
2824+
- CONSUMER
2825+
- SERVER
2826+
- CLIENT
2827+
- PRODUCER
2828+
- INTERNAL
27122829
FormulaAndFunctionApmResourceStatName:
27132830
description: APM resource stat name.
27142831
enum:
@@ -3138,6 +3255,7 @@ components:
31383255
- $ref: "#/components/schemas/FormulaAndFunctionProcessQueryDefinition"
31393256
- $ref: "#/components/schemas/FormulaAndFunctionApmDependencyStatsQueryDefinition"
31403257
- $ref: "#/components/schemas/FormulaAndFunctionApmResourceStatsQueryDefinition"
3258+
- $ref: "#/components/schemas/FormulaAndFunctionApmMetricsQueryDefinition"
31413259
- $ref: "#/components/schemas/FormulaAndFunctionSLOQueryDefinition"
31423260
- $ref: "#/components/schemas/FormulaAndFunctionCloudCostQueryDefinition"
31433261
FormulaAndFunctionResponseFormat:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2025-02-20T10:00:00.000Z"
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"log": {
3+
"_recordingName": "Dashboards/Create a new dashboard with apm metrics widget",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "1cfcf5ccd2e7dff3d4f3b05c53d79057",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 433,
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": 560,
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_apm_metrics_widget-1740045600\",\"widgets\":[{\"definition\":{\"requests\":[{\"queries\":[{\"data_source\":\"apm_metrics\",\"group_by\":[\"resource_name\"],\"name\":\"query1\",\"query_filter\":\"env:prod\",\"service\":\"web-store\",\"stat\":\"hits\"}],\"response_format\":\"scalar\"}],\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"query_table\"},\"layout\":{\"height\":4,\"width\":4,\"x\":0,\"y\":0}}]}"
36+
},
37+
"queryString": [],
38+
"url": "https://api.datadoghq.com/api/v1/dashboard"
39+
},
40+
"response": {
41+
"bodySize": 819,
42+
"content": {
43+
"mimeType": "application/json",
44+
"size": 819,
45+
"text": "{\"id\":\"apm-met-ric\",\"title\":\"Test-Create_a_new_dashboard_with_apm_metrics_widget-1740045600\",\"description\":null,\"author_handle\":\"test@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/apm-met-ric/testcreateanewdashboardwithapmmetricswidget1740045600\",\"is_read_only\":false,\"template_variables\":null,\"widgets\":[{\"definition\":{\"requests\":[{\"queries\":[{\"data_source\":\"apm_metrics\",\"group_by\":[\"resource_name\"],\"name\":\"query1\",\"query_filter\":\"env:prod\",\"service\":\"web-store\",\"stat\":\"hits\"}],\"response_format\":\"scalar\"}],\"title\":\"\",\"title_align\":\"left\",\"title_size\":\"16\",\"type\":\"query_table\"},\"layout\":{\"height\":4,\"width\":4,\"x\":0,\"y\":0},\"id\":1234567890123456}],\"notify_list\":null,\"created_at\":\"2025-02-20T10:00:01.000000+00:00\",\"modified_at\":\"2025-02-20T10:00:01.000000+00:00\",\"restricted_roles\":[]}"
46+
},
47+
"cookies": [],
48+
"headers": [
49+
{
50+
"name": "content-type",
51+
"value": "application/json"
52+
}
53+
],
54+
"headersSize": 381,
55+
"httpVersion": "HTTP/1.1",
56+
"redirectURL": "",
57+
"status": 200,
58+
"statusText": "OK"
59+
},
60+
"startedDateTime": "2025-02-20T10:00:00.015Z",
61+
"time": 430
62+
},
63+
{
64+
"_id": "71162de52581d0f391d949ff27e2aac0",
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/apm-met-ric"
82+
},
83+
"response": {
84+
"bodySize": 38,
85+
"content": {
86+
"mimeType": "application/json",
87+
"size": 38,
88+
"text": "{\"deleted_dashboard_id\":\"apm-met-ric\"}"
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-02-20T10:00:00.460Z",
104+
"time": 380
105+
}
106+
],
107+
"pages": [],
108+
"version": "1.2"
109+
}
110+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Create a new dashboard with apm metrics 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+
definition: {
16+
title: "",
17+
titleSize: "16",
18+
titleAlign: "left",
19+
type: "query_table",
20+
requests: [
21+
{
22+
responseFormat: "scalar",
23+
queries: [
24+
{
25+
stat: "hits",
26+
name: "query1",
27+
service: "web-store",
28+
dataSource: "apm_metrics",
29+
queryFilter: "env:prod",
30+
groupBy: ["resource_name"],
31+
},
32+
],
33+
},
34+
],
35+
},
36+
layout: {
37+
x: 0,
38+
y: 0,
39+
width: 4,
40+
height: 4,
41+
},
42+
},
43+
],
44+
layoutType: "ordered",
45+
},
46+
};
47+
48+
apiInstance
49+
.createDashboard(params)
50+
.then((data: v1.Dashboard) => {
51+
console.log(
52+
"API called successfully. Returned data: " + JSON.stringify(data)
53+
);
54+
})
55+
.catch((error: any) => console.error(error));

features/v1/dashboards.feature

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,20 @@ Feature: Dashboards
329329
And the response "widgets[0].definition.requests[0].queries[0].primary_tag_name" is equal to "datacenter"
330330
And the response "widgets[0].definition.requests[0].queries[0].operation_name" is equal to "cassandra.query"
331331

332+
@team:DataDog/dashboards-backend
333+
Scenario: Create a new dashboard with apm metrics widget
334+
Given new "CreateDashboard" request
335+
And body with value { "title": "{{ unique }}", "widgets": [{"definition": { "title": "", "title_size": "16", "title_align": "left", "type": "query_table", "requests": [ { "response_format": "scalar", "queries": [ { "stat": "hits", "name": "query1", "service": "web-store", "data_source": "apm_metrics", "query_filter": "env:prod", "group_by": ["resource_name"] } ] } ] }, "layout": { "x": 0, "y": 0, "width": 4, "height": 4 } } ], "layout_type": "ordered" }
336+
When the request is sent
337+
Then the response status is 200 OK
338+
And the response "widgets[0].definition.requests[0].response_format" is equal to "scalar"
339+
And the response "widgets[0].definition.requests[0].queries[0].stat" is equal to "hits"
340+
And the response "widgets[0].definition.requests[0].queries[0].group_by[0]" is equal to "resource_name"
341+
And the response "widgets[0].definition.requests[0].queries[0].name" is equal to "query1"
342+
And the response "widgets[0].definition.requests[0].queries[0].service" is equal to "web-store"
343+
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "apm_metrics"
344+
And the response "widgets[0].definition.requests[0].queries[0].query_filter" is equal to "env:prod"
345+
332346
@team:DataDog/dashboards-backend
333347
Scenario: Create a new dashboard with apm resource stats widget
334348
Given new "CreateDashboard" request

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,10 @@ export { EventTimelineWidgetDefinitionType } from "./models/EventTimelineWidgetD
455455
export { FormulaAndFunctionApmDependencyStatName } from "./models/FormulaAndFunctionApmDependencyStatName";
456456
export { FormulaAndFunctionApmDependencyStatsDataSource } from "./models/FormulaAndFunctionApmDependencyStatsDataSource";
457457
export { FormulaAndFunctionApmDependencyStatsQueryDefinition } from "./models/FormulaAndFunctionApmDependencyStatsQueryDefinition";
458+
export { FormulaAndFunctionApmMetricsDataSource } from "./models/FormulaAndFunctionApmMetricsDataSource";
459+
export { FormulaAndFunctionApmMetricsQueryDefinition } from "./models/FormulaAndFunctionApmMetricsQueryDefinition";
460+
export { FormulaAndFunctionApmMetricsSpanKind } from "./models/FormulaAndFunctionApmMetricsSpanKind";
461+
export { FormulaAndFunctionApmMetricStatName } from "./models/FormulaAndFunctionApmMetricStatName";
458462
export { FormulaAndFunctionApmResourceStatName } from "./models/FormulaAndFunctionApmResourceStatName";
459463
export { FormulaAndFunctionApmResourceStatsDataSource } from "./models/FormulaAndFunctionApmResourceStatsDataSource";
460464
export { FormulaAndFunctionApmResourceStatsQueryDefinition } from "./models/FormulaAndFunctionApmResourceStatsQueryDefinition";
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { UnparsedObject } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* APM metric stat name.
11+
*/
12+
13+
export type FormulaAndFunctionApmMetricStatName =
14+
| typeof ERRORS
15+
| typeof ERROR_RATE
16+
| typeof ERRORS_PER_SECOND
17+
| typeof LATENCY_AVG
18+
| typeof LATENCY_MAX
19+
| typeof LATENCY_P50
20+
| typeof LATENCY_P75
21+
| typeof LATENCY_P90
22+
| typeof LATENCY_P95
23+
| typeof LATENCY_P99
24+
| typeof LATENCY_P999
25+
| typeof LATENCY_DISTRIBUTION
26+
| typeof HITS
27+
| typeof HITS_PER_SECOND
28+
| typeof TOTAL_TIME
29+
| typeof APDEX
30+
| UnparsedObject;
31+
export const ERRORS = "errors";
32+
export const ERROR_RATE = "error_rate";
33+
export const ERRORS_PER_SECOND = "errors_per_second";
34+
export const LATENCY_AVG = "latency_avg";
35+
export const LATENCY_MAX = "latency_max";
36+
export const LATENCY_P50 = "latency_p50";
37+
export const LATENCY_P75 = "latency_p75";
38+
export const LATENCY_P90 = "latency_p90";
39+
export const LATENCY_P95 = "latency_p95";
40+
export const LATENCY_P99 = "latency_p99";
41+
export const LATENCY_P999 = "latency_p999";
42+
export const LATENCY_DISTRIBUTION = "latency_distribution";
43+
export const HITS = "hits";
44+
export const HITS_PER_SECOND = "hits_per_second";
45+
export const TOTAL_TIME = "total_time";
46+
export const APDEX = "apdex";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
3+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
4+
* Copyright 2020-Present Datadog, Inc.
5+
*/
6+
7+
import { UnparsedObject } from "../../datadog-api-client-common/util";
8+
9+
/**
10+
* Data source for APM metrics queries.
11+
*/
12+
13+
export type FormulaAndFunctionApmMetricsDataSource =
14+
| typeof APM_METRICS
15+
| UnparsedObject;
16+
export const APM_METRICS = "apm_metrics";

0 commit comments

Comments
 (0)