Skip to content
Open
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
20 changes: 20 additions & 0 deletions datadog/dashboardmapping/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,13 @@ var TimeseriesWidgetSpec = WidgetSpec{
Description: "A nested block describing the right Y-Axis Controls. See the `on_right_yaxis` property for which request will use this axis. The structure of this block is described below.",
Children: widgetAxisFields,
},
{
HCLKey: "anomaly_detection",
Type: TypeBlock,
OmitEmpty: true,
Description: "Anomaly detection configuration for this widget.",
Children: timeseriesWidgetAnomalyDetectionFields,
},
// WidgetMarker: HCL singular "marker" → JSON plural "markers"
{
HCLKey: "marker",
Expand Down Expand Up @@ -1630,6 +1637,19 @@ var timeseriesWidgetRequestStyleFields = []FieldSpec{
},
}

// timeseriesWidgetAnomalyDetectionFields corresponds to OpenAPI
// components/schemas/TimeseriesWidgetAnomalyDetection.
var timeseriesWidgetAnomalyDetectionFields = []FieldSpec{
{
HCLKey: "detection_sensitivity",
Type: TypeString,
OmitEmpty: false,
Required: true,
Description: "Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection.",
ValidValues: []string{"never_detect"},
},
}

// timeseriesWidgetMetadataFields corresponds to the inline metadata object
// on TimeseriesWidgetRequest (no standalone OpenAPI $ref; defined inline).
var timeseriesWidgetMetadataFields = []FieldSpec{
Expand Down
1 change: 1 addition & 0 deletions datadog/tests/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ var testFiles2EndpointTags = map[string]string{
"tests/resource_datadog_dashboard_v2_toplist_display_test": "dashboards",
"tests/resource_datadog_dashboard_v2_query_value_conditional_formats_test": "dashboards",
"tests/resource_datadog_dashboard_v2_timeseries_legend_columns_test": "dashboards",
"tests/resource_datadog_dashboard_v2_timeseries_anomaly_detection_test": "dashboards",
"tests/resource_datadog_dashboard_v2_tab_test": "dashboards",
"tests/resource_datadog_dashboard_v2_treemap_style_sort_test": "dashboards",
"tests/resource_datadog_dashboard_v2_sunburst_sort_test": "dashboards",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package test

import (
"testing"
)

const datadogDashboardV2TimeseriesAnomalyDetectionConfig = `
resource "datadog_dashboard_v2" "timeseries_anomaly_detection_dashboard" {
title = "{{uniq}}"
layout_type = "ordered"

widget {
timeseries_definition {
title = "CPU with anomaly detection"

anomaly_detection {
detection_sensitivity = "never_detect"
}

request {
formula {
formula_expression = "query1"
}

query {
metric_query {
data_source = "metrics"
name = "query1"
query = "avg:system.cpu.user{*}"
}
}
}
}
}
}
`

var datadogDashboardV2TimeseriesAnomalyDetectionAsserts = []string{
"title = {{uniq}}",
"widget.0.timeseries_definition.0.title = CPU with anomaly detection",
"widget.0.timeseries_definition.0.anomaly_detection.0.detection_sensitivity = never_detect",
"widget.0.timeseries_definition.0.request.0.formula.0.formula_expression = query1",
"widget.0.timeseries_definition.0.request.0.query.0.metric_query.0.data_source = metrics",
"widget.0.timeseries_definition.0.request.0.query.0.metric_query.0.name = query1",
"widget.0.timeseries_definition.0.request.0.query.0.metric_query.0.query = avg:system.cpu.user{*}",
}

func TestAccDatadogDashboardV2TimeseriesAnomalyDetection(t *testing.T) {
config, name := datadogDashboardV2TimeseriesAnomalyDetectionConfig, "datadog_dashboard_v2.timeseries_anomaly_detection_dashboard"
testAccDatadogDashboardV2WidgetUtil(t, "TestAccDatadogDashboardV2TimeseriesAnomalyDetection", config, name, datadogDashboardV2TimeseriesAnomalyDetectionAsserts)
}

func TestAccDatadogDashboardV2TimeseriesAnomalyDetection_import(t *testing.T) {
config, name := datadogDashboardV2TimeseriesAnomalyDetectionConfig, "datadog_dashboard_v2.timeseries_anomaly_detection_dashboard"
testAccDatadogDashboardV2WidgetUtilImport(t, "TestAccDatadogDashboardV2TimeseriesAnomalyDetection_import", config, name)
}
27 changes: 27 additions & 0 deletions docs/resources/dashboard_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -13523,6 +13523,7 @@ Required:

Optional:

- `anomaly_detection` (Block List, Max: 1) Anomaly detection configuration for this widget. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--anomaly_detection))
- `custom_link` (Block List) A nested block describing a custom link. Multiple `custom_link` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--custom_link))
- `description` (String) The description of the widget.
- `event` (Block List) The definition of the event to overlay on the graph. Multiple `event` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--event))
Expand All @@ -13541,6 +13542,14 @@ Optional:
- `title_size` (String) The size of the widget's title (defaults to 16).
- `yaxis` (Block List, Max: 1) A nested block describing the Y-Axis Controls. The structure of this block is described below. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--yaxis))

<a id="nestedblock--widget--group_definition--widget--timeseries_definition--anomaly_detection"></a>
### Nested Schema for `widget.group_definition.widget.timeseries_definition.anomaly_detection`

Required:

- `detection_sensitivity` (String) Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection. Valid values are `never_detect`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like there should be different levels as value, but how come the only valid values are never_detect?



<a id="nestedblock--widget--group_definition--widget--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.timeseries_definition.custom_link`

Expand Down Expand Up @@ -28800,6 +28809,7 @@ Required:

Optional:

- `anomaly_detection` (Block List, Max: 1) Anomaly detection configuration for this widget. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--timeseries_definition--anomaly_detection))
- `custom_link` (Block List) A nested block describing a custom link. Multiple `custom_link` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--timeseries_definition--custom_link))
- `description` (String) The description of the widget.
- `event` (Block List) The definition of the event to overlay on the graph. Multiple `event` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--timeseries_definition--event))
Expand All @@ -28818,6 +28828,14 @@ Optional:
- `title_size` (String) The size of the widget's title (defaults to 16).
- `yaxis` (Block List, Max: 1) A nested block describing the Y-Axis Controls. The structure of this block is described below. (see [below for nested schema](#nestedblock--widget--split_graph_definition--source_widget_definition--timeseries_definition--yaxis))

<a id="nestedblock--widget--split_graph_definition--source_widget_definition--timeseries_definition--anomaly_detection"></a>
### Nested Schema for `widget.split_graph_definition.source_widget_definition.timeseries_definition.anomaly_detection`

Required:

- `detection_sensitivity` (String) Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection. Valid values are `never_detect`.


<a id="nestedblock--widget--split_graph_definition--source_widget_definition--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.split_graph_definition.source_widget_definition.timeseries_definition.custom_link`

Expand Down Expand Up @@ -31975,6 +31993,7 @@ Required:

Optional:

- `anomaly_detection` (Block List, Max: 1) Anomaly detection configuration for this widget. (see [below for nested schema](#nestedblock--widget--timeseries_definition--anomaly_detection))
- `custom_link` (Block List) A nested block describing a custom link. Multiple `custom_link` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--timeseries_definition--custom_link))
- `description` (String) The description of the widget.
- `event` (Block List) The definition of the event to overlay on the graph. Multiple `event` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--timeseries_definition--event))
Expand All @@ -31993,6 +32012,14 @@ Optional:
- `title_size` (String) The size of the widget's title (defaults to 16).
- `yaxis` (Block List, Max: 1) A nested block describing the Y-Axis Controls. The structure of this block is described below. (see [below for nested schema](#nestedblock--widget--timeseries_definition--yaxis))

<a id="nestedblock--widget--timeseries_definition--anomaly_detection"></a>
### Nested Schema for `widget.timeseries_definition.anomaly_detection`

Required:

- `detection_sensitivity` (String) Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection. Valid values are `never_detect`.


<a id="nestedblock--widget--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.timeseries_definition.custom_link`

Expand Down
18 changes: 18 additions & 0 deletions docs/resources/powerpack_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -13400,6 +13400,7 @@ Required:

Optional:

- `anomaly_detection` (Block List, Max: 1) Anomaly detection configuration for this widget. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--anomaly_detection))
- `custom_link` (Block List) A nested block describing a custom link. Multiple `custom_link` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--custom_link))
- `description` (String) The description of the widget.
- `event` (Block List) The definition of the event to overlay on the graph. Multiple `event` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--event))
Expand All @@ -13418,6 +13419,14 @@ Optional:
- `title_size` (String) The size of the widget's title (defaults to 16).
- `yaxis` (Block List, Max: 1) A nested block describing the Y-Axis Controls. The structure of this block is described below. (see [below for nested schema](#nestedblock--widget--group_definition--widget--timeseries_definition--yaxis))

<a id="nestedblock--widget--group_definition--widget--timeseries_definition--anomaly_detection"></a>
### Nested Schema for `widget.group_definition.widget.timeseries_definition.anomaly_detection`

Required:

- `detection_sensitivity` (String) Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection. Valid values are `never_detect`.


<a id="nestedblock--widget--group_definition--widget--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.group_definition.widget.timeseries_definition.custom_link`

Expand Down Expand Up @@ -24176,6 +24185,7 @@ Required:

Optional:

- `anomaly_detection` (Block List, Max: 1) Anomaly detection configuration for this widget. (see [below for nested schema](#nestedblock--widget--timeseries_definition--anomaly_detection))
- `custom_link` (Block List) A nested block describing a custom link. Multiple `custom_link` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--timeseries_definition--custom_link))
- `description` (String) The description of the widget.
- `event` (Block List) The definition of the event to overlay on the graph. Multiple `event` blocks are allowed using the structure below. (see [below for nested schema](#nestedblock--widget--timeseries_definition--event))
Expand All @@ -24194,6 +24204,14 @@ Optional:
- `title_size` (String) The size of the widget's title (defaults to 16).
- `yaxis` (Block List, Max: 1) A nested block describing the Y-Axis Controls. The structure of this block is described below. (see [below for nested schema](#nestedblock--widget--timeseries_definition--yaxis))

<a id="nestedblock--widget--timeseries_definition--anomaly_detection"></a>
### Nested Schema for `widget.timeseries_definition.anomaly_detection`

Required:

- `detection_sensitivity` (String) Sensitivity level for anomaly detection. Use `never_detect` to disable anomaly detection. Valid values are `never_detect`.


<a id="nestedblock--widget--timeseries_definition--custom_link"></a>
### Nested Schema for `widget.timeseries_definition.custom_link`

Expand Down
Loading