Skip to content

Commit 08af4af

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add apm_metrics query support to dashboard OpenAPI spec (#3116)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 4b9e584 commit 08af4af

11 files changed

+579
-0
lines changed

.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

cassettes/features/v1/dashboards/Create-a-new-dashboard-with-apm-metrics-widget.yml

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Create a new dashboard with apm metrics widget
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::DashboardsAPI.new
5+
6+
body = DatadogAPIClient::V1::Dashboard.new({
7+
title: "Example-Dashboard",
8+
widgets: [
9+
DatadogAPIClient::V1::Widget.new({
10+
definition: DatadogAPIClient::V1::TableWidgetDefinition.new({
11+
title: "",
12+
title_size: "16",
13+
title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
14+
type: DatadogAPIClient::V1::TableWidgetDefinitionType::QUERY_TABLE,
15+
requests: [
16+
DatadogAPIClient::V1::TableWidgetRequest.new({
17+
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::SCALAR,
18+
queries: [
19+
DatadogAPIClient::V1::FormulaAndFunctionApmMetricsQueryDefinition.new({
20+
stat: DatadogAPIClient::V1::FormulaAndFunctionApmMetricStatName::HITS,
21+
name: "query1",
22+
service: "web-store",
23+
data_source: DatadogAPIClient::V1::FormulaAndFunctionApmMetricsDataSource::APM_METRICS,
24+
query_filter: "env:prod",
25+
group_by: [
26+
"resource_name",
27+
],
28+
}),
29+
],
30+
}),
31+
],
32+
}),
33+
layout: DatadogAPIClient::V1::WidgetLayout.new({
34+
x: 0,
35+
y: 0,
36+
width: 4,
37+
height: 4,
38+
}),
39+
}),
40+
],
41+
layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED,
42+
})
43+
p api_instance.create_dashboard(body)

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

lib/datadog_api_client/inflector.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ def overrides
132132
"v1.formula_and_function_apm_dependency_stat_name" => "FormulaAndFunctionApmDependencyStatName",
133133
"v1.formula_and_function_apm_dependency_stats_data_source" => "FormulaAndFunctionApmDependencyStatsDataSource",
134134
"v1.formula_and_function_apm_dependency_stats_query_definition" => "FormulaAndFunctionApmDependencyStatsQueryDefinition",
135+
"v1.formula_and_function_apm_metrics_data_source" => "FormulaAndFunctionApmMetricsDataSource",
136+
"v1.formula_and_function_apm_metrics_query_definition" => "FormulaAndFunctionApmMetricsQueryDefinition",
137+
"v1.formula_and_function_apm_metrics_span_kind" => "FormulaAndFunctionApmMetricsSpanKind",
138+
"v1.formula_and_function_apm_metric_stat_name" => "FormulaAndFunctionApmMetricStatName",
135139
"v1.formula_and_function_apm_resource_stat_name" => "FormulaAndFunctionApmResourceStatName",
136140
"v1.formula_and_function_apm_resource_stats_data_source" => "FormulaAndFunctionApmResourceStatsDataSource",
137141
"v1.formula_and_function_apm_resource_stats_query_definition" => "FormulaAndFunctionApmResourceStatsQueryDefinition",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
Contact: support@datadoghq.com
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
# APM metric stat name.
21+
class FormulaAndFunctionApmMetricStatName
22+
include BaseEnumModel
23+
24+
ERRORS = "errors".freeze
25+
ERROR_RATE = "error_rate".freeze
26+
ERRORS_PER_SECOND = "errors_per_second".freeze
27+
LATENCY_AVG = "latency_avg".freeze
28+
LATENCY_MAX = "latency_max".freeze
29+
LATENCY_P50 = "latency_p50".freeze
30+
LATENCY_P75 = "latency_p75".freeze
31+
LATENCY_P90 = "latency_p90".freeze
32+
LATENCY_P95 = "latency_p95".freeze
33+
LATENCY_P99 = "latency_p99".freeze
34+
LATENCY_P999 = "latency_p999".freeze
35+
LATENCY_DISTRIBUTION = "latency_distribution".freeze
36+
HITS = "hits".freeze
37+
HITS_PER_SECOND = "hits_per_second".freeze
38+
TOTAL_TIME = "total_time".freeze
39+
APDEX = "apdex".freeze
40+
end
41+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=begin
2+
#Datadog API V1 Collection
3+
4+
#Collection of all Datadog Public endpoints.
5+
6+
The version of the OpenAPI document: 1.0
7+
Contact: support@datadoghq.com
8+
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
9+
10+
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
11+
This product includes software developed at Datadog (https://www.datadoghq.com/).
12+
Copyright 2020-Present Datadog, Inc.
13+
14+
=end
15+
16+
require 'date'
17+
require 'time'
18+
19+
module DatadogAPIClient::V1
20+
# Data source for APM metrics queries.
21+
class FormulaAndFunctionApmMetricsDataSource
22+
include BaseEnumModel
23+
24+
APM_METRICS = "apm_metrics".freeze
25+
end
26+
end

0 commit comments

Comments
 (0)