Skip to content

Support incident_analytics enum in dashboard widget FormulaAndFunctionEventsDataSource data sources #1719

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

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.6",
"regenerated": "2024-07-22 20:03:18.056182",
"spec_repo_commit": "cd020fa6"
"regenerated": "2024-07-23 15:33:50.395018",
"spec_repo_commit": "015355f6"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-07-22 20:03:18.075162",
"spec_repo_commit": "cd020fa6"
"regenerated": "2024-07-23 15:33:50.413026",
"spec_repo_commit": "015355f6"
}
}
}
2 changes: 2 additions & 0 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2867,6 +2867,7 @@ components:
- events
- ci_tests
- ci_pipelines
- incident_analytics
example: logs
type: string
x-enum-varnames:
Expand All @@ -2880,6 +2881,7 @@ components:
- EVENTS
- CI_TESTS
- CI_PIPELINES
- INCIDENT_ANALYTICS
FormulaAndFunctionMetricAggregation:
description: The aggregation methods available for metrics queries.
enum:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"2024-07-23T14:59:59.215Z"
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
{
"log": {
"_recordingName": "Dashboards/Create a new timeseries widget with incident_analytics data source",
"creator": {
"comment": "persister:fs",
"name": "Polly.JS",
"version": "6.0.5"
},
"entries": [
{
"_id": "7463bd2484f9696fa67b31568a8933fd",
"_order": 0,
"cache": {},
"request": {
"bodySize": 681,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
},
{
"_fromType": "array",
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 557,
"httpVersion": "HTTP/1.1",
"method": "POST",
"postData": {
"mimeType": "application/json",
"params": [],
"text": "{\"layout_type\":\"ordered\",\"reflow_type\":\"auto\",\"title\":\"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799 with incident_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\":\"incident_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\"}}]}"
},
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard"
},
"response": {
"bodySize": 1095,
"content": {
"mimeType": "application/json",
"size": 1095,
"text": "{\"id\":\"r29-a2b-nhh\",\"title\":\"Test-Create_a_new_timeseries_widget_with_incident_analytics_data_source-1721746799 with incident_analytics datasource\",\"description\":null,\"author_handle\":\"frog@datadoghq.com\",\"author_name\":null,\"layout_type\":\"ordered\",\"url\":\"/dashboard/r29-a2b-nhh/test-createanewtimeserieswidgetwithincidentanalyticsdatasource-1721746799-with-i\",\"is_read_only\":false,\"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\":\"incident_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\":4216078110414841}],\"notify_list\":null,\"created_at\":\"2024-07-23T14:59:59.491800+00:00\",\"modified_at\":\"2024-07-23T14:59:59.491800+00:00\",\"reflow_type\":\"auto\",\"restricted_roles\":[]}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 657,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-07-23T14:59:59.224Z",
"time": 455
},
{
"_id": "f15c962c8f92d14962e29e114b20212d",
"_order": 0,
"cache": {},
"request": {
"bodySize": 0,
"cookies": [],
"headers": [
{
"_fromType": "array",
"name": "accept",
"value": "application/json"
}
],
"headersSize": 518,
"httpVersion": "HTTP/1.1",
"method": "DELETE",
"queryString": [],
"url": "https://api.datadoghq.com/api/v1/dashboard/r29-a2b-nhh"
},
"response": {
"bodySize": 39,
"content": {
"mimeType": "application/json",
"size": 39,
"text": "{\"deleted_dashboard_id\":\"r29-a2b-nhh\"}\n"
},
"cookies": [],
"headers": [
{
"name": "content-type",
"value": "application/json"
}
],
"headersSize": 655,
"httpVersion": "HTTP/1.1",
"redirectURL": "",
"status": 200,
"statusText": "OK"
},
"startedDateTime": "2024-07-23T14:59:59.685Z",
"time": 222
}
],
"pages": [],
"version": "1.2"
}
}
67 changes: 67 additions & 0 deletions examples/v1/dashboards/CreateDashboard_985012506.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Create a new timeseries widget with incident_analytics data source
*/

import { client, v1 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v1.DashboardsApi(configuration);

const params: v1.DashboardsApiCreateDashboardRequest = {
body: {
title: "Example-Dashboard with incident_analytics datasource",
widgets: [
{
definition: {
title: "",
showLegend: true,
legendLayout: "auto",
legendColumns: ["avg", "min", "max", "value", "sum"],
time: {},
type: "timeseries",
requests: [
{
formulas: [
{
formula: "query1",
},
],
queries: [
{
dataSource: "incident_analytics",
name: "query1",
search: {
query: "test_level:test",
},
indexes: ["*"],
compute: {
aggregation: "count",
},
groupBy: [],
},
],
responseFormat: "timeseries",
style: {
palette: "dog_classic",
lineType: "solid",
lineWidth: "normal",
},
displayType: "line",
},
],
},
},
],
layoutType: "ordered",
reflowType: "auto",
},
};

apiInstance
.createDashboard(params)
.then((data: v1.Dashboard) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
9 changes: 9 additions & 0 deletions features/v1/dashboards.feature
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,15 @@ Feature: Dashboards
And the response "widgets[0].definition.requests[0].queries[0].data_source" is equal to "ci_tests"
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"

@team:DataDog/dashboards-backend
Scenario: Create a new timeseries widget with incident_analytics data source
Given new "CreateDashboard" request
And body with value {"title":"{{ unique }} with incident_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":"incident_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 "incident_analytics"
And the response "widgets[0].definition.requests[0].queries[0].search.query" is equal to "test_level:test"

@generated @skip @team:DataDog/dashboards-backend
Scenario: Create a shared dashboard returns "Bad Request" response
Given new "CreatePublicDashboard" request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type FormulaAndFunctionEventsDataSource =
| typeof EVENTS
| typeof CI_TESTS
| typeof CI_PIPELINES
| typeof INCIDENT_ANALYTICS
| UnparsedObject;
export const LOGS = "logs";
export const SPANS = "spans";
Expand All @@ -32,3 +33,4 @@ export const AUDIT = "audit";
export const EVENTS = "events";
export const CI_TESTS = "ci_tests";
export const CI_PIPELINES = "ci_pipelines";
export const INCIDENT_ANALYTICS = "incident_analytics";
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ const enumsMap: { [key: string]: any[] } = {
"events",
"ci_tests",
"ci_pipelines",
"incident_analytics",
],
FormulaAndFunctionMetricAggregation: [
"avg",
Expand Down
Loading