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

[resource_datadog_dashboard] add support for toplist widget styles in dashboards #2566

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

brtu
Copy link
Contributor

@brtu brtu commented Sep 6, 2024

Background:

This PR is backed on the api-spec change https://github.com/DataDog/datadog-api-spec/pull/3088 which adds the palette field to a toplist widget's style

This PR:

  • Add Terraform support for Toplist widget styles. Style defaults to flat if not specifed
  • Toplist stacked style can specify the palette, palette defaults to datadog128
  • Adds tests for toplist widget with style props
  • Updates relevant documentation

To Test:

  1. Set up test env according to https://datadoghq.atlassian.net/wiki/spaces/DB/pages/3218343160/Working+with+Terraform+Dashboards
  2. Loaded a local Terraform config such as:
resource "datadog_dashboard" "top_list_dashboard" {
	title         = "{{uniq}}"
	description   = "Created using the Datadog provider in Terraform"
	layout_type   = "ordered"
	is_read_only  = "true"

	widget {
		toplist_definition {
			title_size = "16"
			title = "Toplist with flat style"
			title_align = "right"
			live_span = "1w"
			request {
				q = "top(avg:system.cpu.user{*} by {service,app_id}, 10, 'sum', 'desc')"
				conditional_formats {
					palette = "white_on_red"
					value = 15000
					comparator = ">"
				}

			}
      			custom_link {
				link = "https://app.datadoghq.com/dashboard/lists"
				label = "Test Custom Link label"
			}
			custom_link {
				link = "https://app.datadoghq.com/dashboard/lists"
				is_hidden = true
				override_label = "logs"
			}
			style {
				display {
					type = "stacked"
				}
			}

		}

	}


	widget {
		toplist_definition {
			title_size = "16"
			title = "Toplist with stacked style"
			title_align = "right"
			live_span = "1w"
			request {
				q = "top(avg:system.cpu.user{*} by {service,app_id}, 10, 'sum', 'desc')"
				conditional_formats {
					palette = "white_on_red"
					value = 15000
					comparator = ">"
				}
			}
      			custom_link {
				link = "https://app.datadoghq.com/dashboard/lists"
				label = "Test Custom Link label"
			}
			custom_link {
				link = "https://app.datadoghq.com/dashboard/lists"
				is_hidden = true
				override_label = "logs"
			}
			style {
				display {
					type = "stacked"
				}
			}
		}
	}
}
  1. Used terraform apply
  2. Noted dashboard with toplist widgets with styles were created on test env
  3. Also ran unit tests via
% DD_TEST_CLIENT_API_KEY="api-key" DD_TEST_CLIENT_APP_KEY="app-key" TESTARGS="-run TestAccDatadogDashboardTopListWithStyle" RECORD=true make testacc

@brtu brtu force-pushed the bruce.tu/PAYP-28-Toplist-style-def branch from 5c6a1fb to d1c2630 Compare September 9, 2024 02:12
@brtu brtu marked this pull request as ready for review September 9, 2024 02:28
@brtu brtu requested review from a team as code owners September 9, 2024 02:28
@brtu brtu changed the title Dashboards - Toplist Widget - Support flat/stacked widget style and palette [resource_datadog_dashboard] Dashboards - Toplist Widget - Support flat/stacked widget style and palette Sep 9, 2024
hestonhoffman
hestonhoffman previously approved these changes Sep 9, 2024
@brtu
Copy link
Contributor Author

brtu commented Sep 9, 2024

Removed the go.mod and go.sum changes

hyungl
hyungl previously approved these changes Sep 10, 2024
Copy link
Contributor

@hyungl hyungl left a comment

Choose a reason for hiding this comment

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

LGTM but looks like there are conflicting go versions causing checks to fail

@brtu
Copy link
Contributor Author

brtu commented Sep 10, 2024

@hyungl ah yep, goimports had a release yesterday which is why it has that go version error. api-clients team is aware of the issue

@brtu brtu requested a review from hestonhoffman September 11, 2024 17:14
hestonhoffman
hestonhoffman previously approved these changes Sep 11, 2024
remove commment
@brtu brtu dismissed stale reviews from hestonhoffman and hyungl via 2a0a8b6 September 12, 2024 20:34
@brtu brtu force-pushed the bruce.tu/PAYP-28-Toplist-style-def branch from ecbc668 to 2a0a8b6 Compare September 12, 2024 20:34
@brtu
Copy link
Contributor Author

brtu commented Sep 13, 2024

@hestonhoffman @hyungl sorry to re-request reviews on this... will stop rebasing and just merge from now on

@amaskara-dd amaskara-dd changed the title [resource_datadog_dashboard] Dashboards - Toplist Widget - Support flat/stacked widget style and palette [resource_datadog_dashboard] add support for widget styles in dashboards Sep 13, 2024
@amaskara-dd amaskara-dd changed the title [resource_datadog_dashboard] add support for widget styles in dashboards [resource_datadog_dashboard] add support for toplist widget styles in dashboards Sep 13, 2024
@brtu
Copy link
Contributor Author

brtu commented Sep 13, 2024

/merge

@dd-devflow
Copy link

dd-devflow bot commented Sep 13, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in master is 1m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit f974a00 into master Sep 13, 2024
19 checks passed
@dd-mergequeue dd-mergequeue bot deleted the bruce.tu/PAYP-28-Toplist-style-def branch September 13, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants