Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Formula and Function query support to heatmap widgets #1535

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.5",
"regenerated": "2023-09-12 20:28:26.665027",
"spec_repo_commit": "bc2ae18f"
"regenerated": "2023-09-13 14:37:22.081670",
"spec_repo_commit": "ec46249d"
},
"v2": {
"apigentools_version": "1.6.5",
"regenerated": "2023-09-12 20:28:26.677956",
"spec_repo_commit": "bc2ae18f"
"regenerated": "2023-09-13 14:37:22.099316",
"spec_repo_commit": "ec46249d"
}
}
}
12 changes: 12 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3422,6 +3422,11 @@ components:
$ref: '#/components/schemas/LogQueryDefinition'
event_query:
$ref: '#/components/schemas/EventQueryDefinition'
formulas:
description: List of formulas that operate on queries.
items:
$ref: '#/components/schemas/WidgetFormula'
type: array
log_query:
$ref: '#/components/schemas/LogQueryDefinition'
network_query:
Expand All @@ -3433,6 +3438,13 @@ components:
q:
description: Widget query.
type: string
queries:
description: List of queries that can be returned directly or used in formulas.
items:
$ref: '#/components/schemas/FormulaAndFunctionQueryDefinition'
type: array
response_format:
$ref: '#/components/schemas/FormulaAndFunctionResponseFormat'
rum_query:
$ref: '#/components/schemas/LogQueryDefinition'
security_query:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2023-09-12T19:51:40.932Z

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions examples/v1/dashboards/CreateDashboard_3777304439.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Create a new dashboard with formula and function heatmap widget

require "datadog_api_client"
api_instance = DatadogAPIClient::V1::DashboardsAPI.new

body = DatadogAPIClient::V1::Dashboard.new({
title: "Example-Dashboard",
widgets: [
DatadogAPIClient::V1::Widget.new({
layout: DatadogAPIClient::V1::WidgetLayout.new({
x: 0,
y: 0,
width: 47,
height: 15,
}),
definition: DatadogAPIClient::V1::HeatMapWidgetDefinition.new({
title: "",
title_size: "16",
title_align: DatadogAPIClient::V1::WidgetTextAlign::LEFT,
time: DatadogAPIClient::V1::WidgetTime.new({}),
type: DatadogAPIClient::V1::HeatMapWidgetDefinitionType::HEATMAP,
requests: [
DatadogAPIClient::V1::HeatMapWidgetRequest.new({
response_format: DatadogAPIClient::V1::FormulaAndFunctionResponseFormat::TIMESERIES,
queries: [
DatadogAPIClient::V1::FormulaAndFunctionMetricQueryDefinition.new({
data_source: DatadogAPIClient::V1::FormulaAndFunctionMetricDataSource::METRICS,
name: "query1",
query: "avg:system.cpu.user{*}",
}),
],
formulas: [
DatadogAPIClient::V1::WidgetFormula.new({
formula: "query1",
}),
],
style: DatadogAPIClient::V1::WidgetStyle.new({
palette: "dog_classic",
}),
}),
],
}),
}),
],
template_variables: [],
layout_type: DatadogAPIClient::V1::DashboardLayoutType::FREE,
is_read_only: false,
notify_list: [],
})
p api_instance.create_dashboard(body)
11 changes: 11 additions & 0 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,17 @@ Feature: Dashboards
And the response "widgets[0].definition.type" is equal to "event_timeline"
And the response "widgets[0].definition.query" is equal to "status:error priority:all"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with formula and function heatmap widget
Given new "CreateDashboard" request
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": []}
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.type" is equal to "heatmap"
And the response "widgets[0].definition.requests[0].queries[0].query" is equal to "avg:system.cpu.user{*}"
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "metrics"
And the response "widgets[0].definition.requests[0].style.palette" is equal to "dog_classic"

@team:DataDog/dashboards-backend
Scenario: Create a new dashboard with formulas and functions scatterplot widget
Given new "CreateDashboard" request
Expand Down
36 changes: 35 additions & 1 deletion lib/datadog_api_client/v1/models/heat_map_widget_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class HeatMapWidgetRequest
# The event query.
attr_accessor :event_query

# List of formulas that operate on queries.
attr_accessor :formulas

# The log query.
attr_accessor :log_query

Expand All @@ -42,6 +45,12 @@ class HeatMapWidgetRequest
# Widget query.
attr_accessor :q

# List of queries that can be returned directly or used in formulas.
attr_accessor :queries

# Timeseries, scalar, or event list response. Event list response formats are supported by Geomap widgets.
attr_accessor :response_format

# The log query.
attr_accessor :rum_query

Expand All @@ -57,11 +66,14 @@ def self.attribute_map
{
:'apm_query' => :'apm_query',
:'event_query' => :'event_query',
:'formulas' => :'formulas',
:'log_query' => :'log_query',
:'network_query' => :'network_query',
:'process_query' => :'process_query',
:'profile_metrics_query' => :'profile_metrics_query',
:'q' => :'q',
:'queries' => :'queries',
:'response_format' => :'response_format',
:'rum_query' => :'rum_query',
:'security_query' => :'security_query',
:'style' => :'style'
Expand All @@ -74,11 +86,14 @@ def self.openapi_types
{
:'apm_query' => :'LogQueryDefinition',
:'event_query' => :'EventQueryDefinition',
:'formulas' => :'Array<WidgetFormula>',
:'log_query' => :'LogQueryDefinition',
:'network_query' => :'LogQueryDefinition',
:'process_query' => :'ProcessQueryDefinition',
:'profile_metrics_query' => :'LogQueryDefinition',
:'q' => :'String',
:'queries' => :'Array<FormulaAndFunctionQueryDefinition>',
:'response_format' => :'FormulaAndFunctionResponseFormat',
:'rum_query' => :'LogQueryDefinition',
:'security_query' => :'LogQueryDefinition',
:'style' => :'WidgetStyle'
Expand Down Expand Up @@ -109,6 +124,12 @@ def initialize(attributes = {})
self.event_query = attributes[:'event_query']
end

if attributes.key?(:'formulas')
if (value = attributes[:'formulas']).is_a?(Array)
self.formulas = value
end
end

if attributes.key?(:'log_query')
self.log_query = attributes[:'log_query']
end
Expand All @@ -129,6 +150,16 @@ def initialize(attributes = {})
self.q = attributes[:'q']
end

if attributes.key?(:'queries')
if (value = attributes[:'queries']).is_a?(Array)
self.queries = value
end
end

if attributes.key?(:'response_format')
self.response_format = attributes[:'response_format']
end

if attributes.key?(:'rum_query')
self.rum_query = attributes[:'rum_query']
end
Expand All @@ -150,11 +181,14 @@ def ==(o)
self.class == o.class &&
apm_query == o.apm_query &&
event_query == o.event_query &&
formulas == o.formulas &&
log_query == o.log_query &&
network_query == o.network_query &&
process_query == o.process_query &&
profile_metrics_query == o.profile_metrics_query &&
q == o.q &&
queries == o.queries &&
response_format == o.response_format &&
rum_query == o.rum_query &&
security_query == o.security_query &&
style == o.style
Expand All @@ -164,7 +198,7 @@ def ==(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[apm_query, event_query, log_query, network_query, process_query, profile_metrics_query, q, rum_query, security_query, style].hash
[apm_query, event_query, formulas, log_query, network_query, process_query, profile_metrics_query, q, queries, response_format, rum_query, security_query, style].hash
end
end
end
Loading