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

[datadog_dashboard] Add clustering_pattern_field_path and group_by for ListStream Widget #2869

Merged
merged 6 commits into from
Feb 28, 2025
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
31 changes: 31 additions & 0 deletions datadog/resource_datadog_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5902,6 +5902,11 @@ func getListStreamRequestSchema() map[string]*schema.Schema {
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"clustering_pattern_field_path": {
Description: "Specifies the field for logs pattern clustering. Can only be used with `logs_pattern_stream`.",
Optional: true,
Type: schema.TypeString,
},
"data_source": {
Description: "Source from which to query items to display in the stream.",
Type: schema.TypeString,
Expand All @@ -5919,6 +5924,20 @@ func getListStreamRequestSchema() map[string]*schema.Schema {
Optional: true,
ValidateDiagFunc: validators.ValidateEnumValue(datadogV1.NewWidgetEventSizeFromValue),
},
"group_by": {
Description: "Group by configuration for the List Stream widget. Group by can only be used with `logs_pattern_stream` (up to 4 items) or `logs_transaction_stream` (one group by item is required) list stream source.",
Optional: true,
Type: schema.TypeList,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"facet": {
Description: "Facet name",
Type: schema.TypeString,
Required: true,
},
},
},
},
"indexes": {
Description: "List of indexes.",
Type: schema.TypeList,
Expand Down Expand Up @@ -5974,6 +5993,9 @@ func buildDatadogListStreamRequests(terraformRequests *[]interface{}) *[]datadog

if terraformQuery, ok := terraformRequest["query"].([]interface{}); ok && len(terraformQuery) > 0 {
q := terraformQuery[0].(map[string]interface{})
if v, ok := q["clustering_pattern_field_path"].(string); ok && len(v) > 0 {
datadogQuery.SetClusteringPatternFieldPath(v)
}
if v, ok := q["data_source"].(string); ok && len(v) > 0 {
ds := datadogV1.ListStreamSource(v)
datadogQuery.SetDataSource(ds)
Expand All @@ -5987,13 +6009,22 @@ func buildDatadogListStreamRequests(terraformRequests *[]interface{}) *[]datadog
if v, ok := q["storage"].(string); ok && v != "" {
datadogQuery.SetStorage(v)
}
if v, ok := q["group_by"].([]interface{}); ok {
var groupBy []datadogV1.ListStreamGroupByItems
for _, s := range v {
facet := s.(map[string]interface{})["facet"].(string)
groupBy = append(groupBy, *datadogV1.NewListStreamGroupByItems(facet))
}
datadogQuery.SetGroupBy(groupBy)
}
if v, ok := q["indexes"].([]interface{}); ok {
var indexes []string
for _, s := range v {
indexes = append(indexes, s.(string))
}
datadogQuery.SetIndexes(indexes)
}

if terraformSort, ok := q["sort"].([]interface{}); ok && len(terraformSort) > 0 {
sortMap := terraformSort[0].(map[string]interface{})
datadogSort := datadogV1.NewWidgetFieldSortWithDefaults()
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:28.013594-04:00
2025-02-26T10:54:29.592022+01:00
696 changes: 454 additions & 242 deletions datadog/tests/cassettes/TestAccDatadogDashboardRbac_adminToRbac.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:15.344196-04:00
2025-02-26T10:54:52.103327+01:00
272 changes: 179 additions & 93 deletions datadog/tests/cassettes/TestAccDatadogDashboardRbac_createAdmin.yaml
Original file line number Diff line number Diff line change
@@ -1,95 +1,181 @@
---
version: 2
interactions:
- request:
body: |
{"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"tags":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1682003475","widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"}}]}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard
method: POST
id: 0
response:
body: |
{"id":"2ad-xgf-xws","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1682003475","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/2ad-xgf-xws/tf-testaccdatadogdashboardrbaccreateadmin-local-1682003475","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1104433575338262}],"notify_list":[],"created_at":"2023-04-20T15:11:16.771360+00:00","modified_at":"2023-04-20T15:11:16.771360+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: "0ms"
- request:
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/2ad-xgf-xws
method: GET
id: 1
response:
body: |
{"id":"2ad-xgf-xws","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1682003475","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/2ad-xgf-xws/tf-testaccdatadogdashboardrbaccreateadmin-local-1682003475","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1104433575338262}],"notify_list":[],"created_at":"2023-04-20T15:11:16.771360+00:00","modified_at":"2023-04-20T15:11:16.771360+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: "0ms"
- request:
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/2ad-xgf-xws
method: GET
id: 2
response:
body: |
{"id":"2ad-xgf-xws","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1682003475","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/2ad-xgf-xws/tf-testaccdatadogdashboardrbaccreateadmin-local-1682003475","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1104433575338262}],"notify_list":[],"created_at":"2023-04-20T15:11:16.771360+00:00","modified_at":"2023-04-20T15:11:16.771360+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: "0ms"
- request:
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/2ad-xgf-xws
method: GET
id: 3
response:
body: |
{"id":"2ad-xgf-xws","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1682003475","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/2ad-xgf-xws/tf-testaccdatadogdashboardrbaccreateadmin-local-1682003475","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1104433575338262}],"notify_list":[],"created_at":"2023-04-20T15:11:16.771360+00:00","modified_at":"2023-04-20T15:11:16.771360+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: "0ms"
- request:
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/2ad-xgf-xws
method: DELETE
id: 4
response:
body: |
{"deleted_dashboard_id":"2ad-xgf-xws"}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: "0ms"
- id: 0
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 372
transfer_encoding: []
trailer: {}
host: api.datadoghq.com
remote_addr: ""
request_uri: ""
body: |
{"description":"Created using the Datadog provider in Terraform","id":"","is_read_only":true,"layout_type":"ordered","notify_list":[],"tags":[],"template_variable_presets":[],"template_variables":[],"title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1740563692","widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"}}]}
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard
method: POST
response:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
transfer_encoding:
- chunked
trailer: {}
content_length: -1
uncompressed: true
body: |
{"id":"hc4-sji-z9f","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1740563692","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":"frog","layout_type":"ordered","url":"/dashboard/hc4-sji-z9f/tf-testaccdatadogdashboardrbaccreateadmin-local-1740563692","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1124699396934005}],"notify_list":[],"created_at":"2025-02-26T09:54:54.975769+00:00","modified_at":"2025-02-26T09:54:54.975769+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 682.707625ms
- id: 1
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: api.datadoghq.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/hc4-sji-z9f
method: GET
response:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
transfer_encoding:
- chunked
trailer: {}
content_length: -1
uncompressed: true
body: |
{"id":"hc4-sji-z9f","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1740563692","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":"frog","layout_type":"ordered","url":"/dashboard/hc4-sji-z9f/tf-testaccdatadogdashboardrbaccreateadmin-local-1740563692","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1124699396934005}],"notify_list":[],"created_at":"2025-02-26T09:54:54.975769+00:00","modified_at":"2025-02-26T09:54:54.975769+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 156.982875ms
- id: 2
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: api.datadoghq.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/hc4-sji-z9f
method: GET
response:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
transfer_encoding:
- chunked
trailer: {}
content_length: -1
uncompressed: true
body: |
{"id":"hc4-sji-z9f","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1740563692","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":"frog","layout_type":"ordered","url":"/dashboard/hc4-sji-z9f/tf-testaccdatadogdashboardrbaccreateadmin-local-1740563692","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1124699396934005}],"notify_list":[],"created_at":"2025-02-26T09:54:54.975769+00:00","modified_at":"2025-02-26T09:54:54.975769+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 172.397541ms
- id: 3
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: api.datadoghq.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/hc4-sji-z9f
method: GET
response:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
transfer_encoding:
- chunked
trailer: {}
content_length: -1
uncompressed: true
body: |
{"id":"hc4-sji-z9f","title":"tf-TestAccDatadogDashboardRbac_createAdmin-local-1740563692","description":"Created using the Datadog provider in Terraform","author_handle":"[email protected]","author_name":"frog","layout_type":"ordered","url":"/dashboard/hc4-sji-z9f/tf-testaccdatadogdashboardrbaccreateadmin-local-1740563692","is_read_only":true,"template_variables":[],"widgets":[{"definition":{"content":"note text","has_padding":true,"show_tick":false,"type":"note"},"id":1124699396934005}],"notify_list":[],"created_at":"2025-02-26T09:54:54.975769+00:00","modified_at":"2025-02-26T09:54:54.975769+00:00","template_variable_presets":[],"tags":[]}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 153.387667ms
- id: 4
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 0
transfer_encoding: []
trailer: {}
host: api.datadoghq.com
remote_addr: ""
request_uri: ""
body: ""
form: {}
headers:
Accept:
- application/json
url: https://api.datadoghq.com/api/v1/dashboard/hc4-sji-z9f
method: DELETE
response:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
transfer_encoding:
- chunked
trailer: {}
content_length: -1
uncompressed: true
body: |
{"deleted_dashboard_id":"hc4-sji-z9f"}
headers:
Content-Type:
- application/json
status: 200 OK
code: 200
duration: 214.088125ms
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2023-04-20T11:11:35.569273-04:00
2025-02-26T10:55:09.667529+01:00
Loading