Skip to content

Commit 2378b7a

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

11 files changed

+240
-3
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

cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-timeseries-widget-using-formulas-and-functions-metrics-query-with-combined-semantic-mode.yml

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2025-12-08T18:32:38.191Z

cassettes/features/v1/dashboards/Create-a-new-dashboard-with-a-timeseries-widget-using-formulas-and-functions-metrics-query-with-native-semantic-mode.yml

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Create a new dashboard with a timeseries widget using formulas and functions metrics query with native semantic_mode
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::DashboardsAPI.new
5+
6+
body = DatadogAPIClient::V1::Dashboard.new({
7+
layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED,
8+
title: "Example-Dashboard with native semantic_mode",
9+
widgets: [
10+
DatadogAPIClient::V1::Widget.new({
11+
definition: DatadogAPIClient::V1::TimeseriesWidgetDefinition.new({
12+
type: DatadogAPIClient::V1::TimeseriesWidgetDefinitionType::TIMESERIES,
13+
requests: [
14+
DatadogAPIClient::V1::TimeseriesWidgetRequest.new({
15+
queries: [
16+
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
17+
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
18+
name: "query1",
19+
query: "avg:system.cpu.user{*}",
20+
semantic_mode: DatadogAPIClient::V1::FormulaAndFunctionMetricSemanticMode::NATIVE,
21+
}),
22+
],
23+
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::TIMESERIES,
24+
formulas: [
25+
DatadogAPIClient::V1::WidgetFormula.new({
26+
formula: "query1",
27+
}),
28+
],
29+
display_type: DatadogAPIClient::V1::WidgetDisplayType::LINE,
30+
}),
31+
],
32+
}),
33+
}),
34+
],
35+
})
36+
p api_instance.create_dashboard(body)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Create a new dashboard with a timeseries widget using formulas and functions metrics query with combined semantic_mode
2+
3+
require "datadog_api_client"
4+
api_instance = DatadogAPIClient::V1::DashboardsAPI.new
5+
6+
body = DatadogAPIClient::V1::Dashboard.new({
7+
layout_type: DatadogAPIClient::V1::DashboardLayoutType::ORDERED,
8+
title: "Example-Dashboard with combined semantic_mode",
9+
widgets: [
10+
DatadogAPIClient::V1::Widget.new({
11+
definition: DatadogAPIClient::V1::TimeseriesWidgetDefinition.new({
12+
type: DatadogAPIClient::V1::TimeseriesWidgetDefinitionType::TIMESERIES,
13+
requests: [
14+
DatadogAPIClient::V1::TimeseriesWidgetRequest.new({
15+
queries: [
16+
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
17+
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
18+
name: "query1",
19+
query: "avg:system.cpu.user{*}",
20+
semantic_mode: DatadogAPIClient::V1::FormulaAndFunctionMetricSemanticMode::COMBINED,
21+
}),
22+
],
23+
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::TIMESERIES,
24+
formulas: [
25+
DatadogAPIClient::V1::WidgetFormula.new({
26+
formula: "query1",
27+
}),
28+
],
29+
display_type: DatadogAPIClient::V1::WidgetDisplayType::LINE,
30+
}),
31+
],
32+
}),
33+
}),
34+
],
35+
})
36+
p api_instance.create_dashboard(body)

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

lib/datadog_api_client/inflector.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ def overrides
134134
"v1.formula_and_function_metric_aggregation" => "FormulaAndFunctionMetricAggregation",
135135
"v1.formula_and_function_metric_data_source" => "FormulaAndFunctionMetricDataSource",
136136
"v1.formula_and_function_metric_query_definition" => "FormulaAndFunctionMetricQueryDefinition",
137+
"v1.formula_and_function_metric_semantic_mode" => "FormulaAndFunctionMetricSemanticMode",
137138
"v1.formula_and_function_process_query_data_source" => "FormulaAndFunctionProcessQueryDataSource",
138139
"v1.formula_and_function_process_query_definition" => "FormulaAndFunctionProcessQueryDefinition",
139140
"v1.formula_and_function_query_definition" => "FormulaAndFunctionQueryDefinition",

lib/datadog_api_client/v1/models/formula_and_function_metric_query_definition.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class FormulaAndFunctionMetricQueryDefinition
3636
# Metrics query definition.
3737
attr_reader :query
3838

39+
# Semantic mode for metrics queries. This determines how metrics from different sources are combined or displayed.
40+
attr_accessor :semantic_mode
41+
3942
attr_accessor :additional_properties
4043

4144
# Attribute mapping from ruby-style variable name to JSON key.
@@ -46,7 +49,8 @@ def self.attribute_map
4649
:'cross_org_uuids' => :'cross_org_uuids',
4750
:'data_source' => :'data_source',
4851
:'name' => :'name',
49-
:'query' => :'query'
52+
:'query' => :'query',
53+
:'semantic_mode' => :'semantic_mode'
5054
}
5155
end
5256

@@ -58,7 +62,8 @@ def self.openapi_types
5862
:'cross_org_uuids' => :'Array<String>',
5963
:'data_source' => :'FormulaAndFunctionMetricDataSource',
6064
:'name' => :'String',
61-
:'query' => :'String'
65+
:'query' => :'String',
66+
:'semantic_mode' => :'FormulaAndFunctionMetricSemanticMode'
6267
}
6368
end
6469

@@ -101,6 +106,10 @@ def initialize(attributes = {})
101106
if attributes.key?(:'query')
102107
self.query = attributes[:'query']
103108
end
109+
110+
if attributes.key?(:'semantic_mode')
111+
self.semantic_mode = attributes[:'semantic_mode']
112+
end
104113
end
105114

106115
# Check to see if the all the properties in the model are valid
@@ -185,14 +194,15 @@ def ==(o)
185194
data_source == o.data_source &&
186195
name == o.name &&
187196
query == o.query &&
197+
semantic_mode == o.semantic_mode &&
188198
additional_properties == o.additional_properties
189199
end
190200

191201
# Calculates hash code according to all attributes.
192202
# @return [Integer] Hash code
193203
# @!visibility private
194204
def hash
195-
[aggregator, cross_org_uuids, data_source, name, query, additional_properties].hash
205+
[aggregator, cross_org_uuids, data_source, name, query, semantic_mode, additional_properties].hash
196206
end
197207
end
198208
end

0 commit comments

Comments
 (0)