Skip to content
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
2 changes: 2 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,7 @@ components:
- ci_tests
- ci_pipelines
- incident_analytics
- product_analytics
example: logs
type: string
x-enum-varnames:
Expand All @@ -2889,6 +2890,7 @@ components:
- CI_TESTS
- CI_PIPELINES
- INCIDENT_ANALYTICS
- PRODUCT_ANALYTICS
FormulaAndFunctionMetricAggregation:
description: The aggregation methods available for metrics queries.
enum:
Expand Down
96 changes: 96 additions & 0 deletions examples/v1/dashboards/CreateDashboard_607525069.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""
Create a new timeseries widget with product_analytics data source
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.dashboards_api import DashboardsApi
from datadog_api_client.v1.model.dashboard import Dashboard
from datadog_api_client.v1.model.dashboard_layout_type import DashboardLayoutType
from datadog_api_client.v1.model.dashboard_reflow_type import DashboardReflowType
from datadog_api_client.v1.model.formula_and_function_event_aggregation import FormulaAndFunctionEventAggregation
from datadog_api_client.v1.model.formula_and_function_event_query_definition import (
FormulaAndFunctionEventQueryDefinition,
)
from datadog_api_client.v1.model.formula_and_function_event_query_definition_compute import (
FormulaAndFunctionEventQueryDefinitionCompute,
)
from datadog_api_client.v1.model.formula_and_function_event_query_definition_search import (
FormulaAndFunctionEventQueryDefinitionSearch,
)
from datadog_api_client.v1.model.formula_and_function_events_data_source import FormulaAndFunctionEventsDataSource
from datadog_api_client.v1.model.formula_and_function_response_format import FormulaAndFunctionResponseFormat
from datadog_api_client.v1.model.timeseries_widget_definition import TimeseriesWidgetDefinition
from datadog_api_client.v1.model.timeseries_widget_definition_type import TimeseriesWidgetDefinitionType
from datadog_api_client.v1.model.timeseries_widget_legend_column import TimeseriesWidgetLegendColumn
from datadog_api_client.v1.model.timeseries_widget_legend_layout import TimeseriesWidgetLegendLayout
from datadog_api_client.v1.model.timeseries_widget_request import TimeseriesWidgetRequest
from datadog_api_client.v1.model.widget import Widget
from datadog_api_client.v1.model.widget_display_type import WidgetDisplayType
from datadog_api_client.v1.model.widget_formula import WidgetFormula
from datadog_api_client.v1.model.widget_legacy_live_span import WidgetLegacyLiveSpan
from datadog_api_client.v1.model.widget_line_type import WidgetLineType
from datadog_api_client.v1.model.widget_line_width import WidgetLineWidth
from datadog_api_client.v1.model.widget_request_style import WidgetRequestStyle

body = Dashboard(
title="Example-Dashboard with product_analytics datasource",
widgets=[
Widget(
definition=TimeseriesWidgetDefinition(
title="",
show_legend=True,
legend_layout=TimeseriesWidgetLegendLayout.AUTO,
legend_columns=[
TimeseriesWidgetLegendColumn.AVG,
TimeseriesWidgetLegendColumn.MIN,
TimeseriesWidgetLegendColumn.MAX,
TimeseriesWidgetLegendColumn.VALUE,
TimeseriesWidgetLegendColumn.SUM,
],
time=WidgetLegacyLiveSpan(),
type=TimeseriesWidgetDefinitionType.TIMESERIES,
requests=[
TimeseriesWidgetRequest(
formulas=[
WidgetFormula(
formula="query1",
),
],
queries=[
FormulaAndFunctionEventQueryDefinition(
data_source=FormulaAndFunctionEventsDataSource.PRODUCT_ANALYTICS,
name="query1",
search=FormulaAndFunctionEventQueryDefinitionSearch(
query="test_level:test",
),
indexes=[
"*",
],
compute=FormulaAndFunctionEventQueryDefinitionCompute(
aggregation=FormulaAndFunctionEventAggregation.COUNT,
),
group_by=[],
),
],
response_format=FormulaAndFunctionResponseFormat.TIMESERIES,
style=WidgetRequestStyle(
palette="dog_classic",
line_type=WidgetLineType.SOLID,
line_width=WidgetLineWidth.NORMAL,
),
display_type=WidgetDisplayType.LINE,
),
],
),
),
],
layout_type=DashboardLayoutType.ORDERED,
reflow_type=DashboardReflowType.AUTO,
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
api_instance = DashboardsApi(api_client)
response = api_instance.create_dashboard(body=body)

print(response)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
"""
Data source for event platform-based queries.

:param value: Must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", "events", "ci_tests", "ci_pipelines", "incident_analytics"].
:param value: Must be one of ["logs", "spans", "network", "rum", "security_signals", "profiles", "audit", "events", "ci_tests", "ci_pipelines", "incident_analytics", "product_analytics"].
:type value: str
"""

Expand All @@ -32,6 +32,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
"ci_tests",
"ci_pipelines",
"incident_analytics",
"product_analytics",
}
LOGS: ClassVar["FormulaAndFunctionEventsDataSource"]
SPANS: ClassVar["FormulaAndFunctionEventsDataSource"]
Expand All @@ -44,6 +45,7 @@ class FormulaAndFunctionEventsDataSource(ModelSimple):
CI_TESTS: ClassVar["FormulaAndFunctionEventsDataSource"]
CI_PIPELINES: ClassVar["FormulaAndFunctionEventsDataSource"]
INCIDENT_ANALYTICS: ClassVar["FormulaAndFunctionEventsDataSource"]
PRODUCT_ANALYTICS: ClassVar["FormulaAndFunctionEventsDataSource"]

@cached_property
def openapi_types(_):
Expand All @@ -63,3 +65,4 @@ def openapi_types(_):
FormulaAndFunctionEventsDataSource.CI_TESTS = FormulaAndFunctionEventsDataSource("ci_tests")
FormulaAndFunctionEventsDataSource.CI_PIPELINES = FormulaAndFunctionEventsDataSource("ci_pipelines")
FormulaAndFunctionEventsDataSource.INCIDENT_ANALYTICS = FormulaAndFunctionEventsDataSource("incident_analytics")
FormulaAndFunctionEventsDataSource.PRODUCT_ANALYTICS = FormulaAndFunctionEventsDataSource("product_analytics")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2025-09-18T18:51:17.951Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
interactions:
- request:
body: '{"layout_type":"ordered","reflow_type":"auto","title":"Test-Create_a_new_timeseries_widget_with_product_analytics_data_source-1758221477
with product_analytics datasource","widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"product_analytics","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"test_level:test"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"}}]}'
headers:
accept:
- application/json
content-type:
- application/json
method: POST
uri: https://api.datadoghq.com/api/v1/dashboard
response:
body:
string: '{"id":"zvr-td5-ppm","title":"Test-Create_a_new_timeseries_widget_with_product_analytics_data_source-1758221477
with product_analytics datasource","description":null,"author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI
Account","layout_type":"ordered","url":"/dashboard/zvr-td5-ppm/test-createanewtimeserieswidgetwithproductanalyticsdatasource-1758221477-with-pr","template_variables":null,"widgets":[{"definition":{"legend_columns":["avg","min","max","value","sum"],"legend_layout":"auto","requests":[{"display_type":"line","formulas":[{"formula":"query1"}],"queries":[{"compute":{"aggregation":"count"},"data_source":"product_analytics","group_by":[],"indexes":["*"],"name":"query1","search":{"query":"test_level:test"}}],"response_format":"timeseries","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"show_legend":true,"time":{},"title":"","type":"timeseries"},"id":6058978575853641}],"notify_list":null,"created_at":"2025-09-18T18:51:18.107135+00:00","modified_at":"2025-09-18T18:51:18.107135+00:00","reflow_type":"auto","restricted_roles":[]}'
headers:
content-type:
- application/json
status:
code: 200
message: OK
- request:
body: null
headers:
accept:
- application/json
method: DELETE
uri: https://api.datadoghq.com/api/v1/dashboard/zvr-td5-ppm
response:
body:
string: '{"deleted_dashboard_id":"zvr-td5-ppm"}

'
headers:
content-type:
- application/json
status:
code: 200
message: OK
version: 1
9 changes: 9 additions & 0 deletions tests/v1/features/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,15 @@ Feature: Dashboards
And the response "widgets[0].definition.time.value" is equal to 8
And the response "widgets[0].definition.time.hide_incomplete_cost_data" is equal to true

@team:DataDog/dashboards-backend
Scenario: Create a new timeseries widget with product_analytics data source
Given new "CreateDashboard" request
And body with value {"title":"{{ unique }} with product_analytics datasource","widgets":[{"definition":{"title":"","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"formulas":[{"formula":"query1"}],"queries":[{"data_source":"product_analytics","name":"query1","search":{"query":"test_level:test"},"indexes":["*"],"compute":{"aggregation":"count"},"group_by":[]}],"response_format":"timeseries","style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]}}],"layout_type":"ordered","reflow_type":"auto"}
When the request is sent
Then the response status is 200 OK
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "product_analytics"
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"

@generated @skip @team:DataDog/reporting-and-sharing
Scenario: Create a shared dashboard returns "Bad Request" response
Given new "CreatePublicDashboard" request
Expand Down