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_powerpacks] Implement support for live span and more widgets #2158

Merged
merged 45 commits into from
Nov 14, 2023

Conversation

dashashifrina
Copy link
Contributor

@dashashifrina dashashifrina commented Oct 24, 2023

This pull request implements the second part of the support for the powerpack resource in Terraform.

Previous PR:

Changes

  • Add support for setting live_span in powerpack. In regular dashboard widgets, live_span is set at the widget level NOT resource level. For example, event_stream and trace_service widgets use live_span, within a powerpack, we set live_span under the group_widget object instead. With these changes, users will be redirected to set a live_span property at the powerpack resource level if they attempt to set it at the widget level.
  • Add support for widgets with request LIST property (note: there are some widgets that define request as a single value and will be handled in a follow up)
  • Add support for widgets with custom_link LIST property
  • Add support for:
    • alert_value
    • change
    • event_stream
    • event_timeline
    • manage_status
    • query_value
    • toplist
    • trace_service
  • Add test and recorded cassettes for all the widgets listed above.
  • Add doc.

How to test:

  1. Build the provider locally.
  2. Try this powerpack resource with all the supported widgets:
resource "datadog_powerpack" "foo2" {
    name = "Sample Powerpack"
    tags = ["tag:foo1", "tag:foo2"]
    description = "Test Powerpack 2"

  template_variables {
    defaults = ["defaults"]
    name     = "datacenter"
  }
  widget {
    alert_value_definition {
	    alert_id = "895605"
    }
  }
  widget {
    alert_value_definition {
	    alert_id = "895606"
	    precision = 1
	    unit = "b"
	    title_size = "16"
	    title_align = "center"
	    title = "Widget Title"
	    text_align = "center"
    }
  }
   widget {
      change_definition {
		      request {
	      q             = "avg:system.load.1{env:staging} by {account}"
	      change_type   = "absolute"
	      compare_to    = "week_before"
	      increase_good = true
	      order_by      = "name"
	      order_dir     = "desc"
	      show_present  = false
		      }
		      title     = "Widget Title"
      }
   }
  widget {
    event_stream_definition {
      query       = "*"
      event_size  = "l"
      title       = "Widget Title"
      title_size  = 16
      title_align = "right"
    }
  }
  widget {
    manage_status_definition {
	    sort = "triggered,desc"
	    title_size = "20"
	    title = ""
	    title_align = "center"
	    hide_zero_counts = true
	    summary_type = "combined"
	    color_preference = "background"
	    query = "env:prod group_status:alert"
	    show_last_triggered = true
	    display_format = "countsAndList"
    }
    widget_layout {
	    height = 6
	    width = 4
	    x = 5
	    y = 5
    }
  }
  widget {
    trace_service_definition {
      display_format     = "three_column"
      env                = "datadog.com"
      service            = "alerting-cassandra"
      show_breakdown     = true
      show_distribution  = true
      show_errors        = true
      show_hits          = true
      show_latency       = false
      show_resource_list = false
      size_format        = "large"
      span_name          = "cassandra.query"
      title              = "alerting-cassandra #env:datadog.com"
      title_align        = "center"
      title_size         = "13"
    }
  }
  widget {
    event_timeline_definition {
      title = "Widget Title"
      title_align = "right"
      title_size = "16"
      tags_execution = "and"
      query = "status:error"
    }
    widget_layout {
      height = 4
      width = 3
      x = 5
      y = 5
    }
  }
  widget {
    query_value_definition {
      request {
        q          = "avg:system.load.1{env:staging} by {account}"
        aggregator = "sum"
        conditional_formats {
          comparator = "<"
          value      = "2"
          palette    = "white_on_green"
        }
        conditional_formats {
          comparator = ">"
          value      = "2.2"
          palette    = "white_on_red"
        }
      }
      autoscale   = true
      custom_unit = "xx"
      precision   = "4"
      text_align  = "right"
      title       = "Widget Title"
    }
  }
  widget {
    toplist_definition {
      request {
        q = "avg:system.cpu.user{app:general} by {datacenter}"
        conditional_formats {
          comparator = "<"
          value      = "2"
          palette    = "white_on_green"
        }
        conditional_formats {
          comparator = ">"
          value      = "2.2"
          palette    = "white_on_red"
        }
      }
      title = "Widget Title"
    }
  }
}

@dashashifrina dashashifrina force-pushed the dasha.shifrina/powerpacks-pt-2 branch from d06c5ca to 9dd1332 Compare October 24, 2023 21:12
@dashashifrina dashashifrina changed the title support for event stream and trace service, live span for widgets [datadog_powerpacks] Implement support for live span and more widgets Oct 24, 2023
@dashashifrina dashashifrina force-pushed the dasha.shifrina/powerpacks-pt-2 branch from 7e9f179 to 7b3551d Compare October 25, 2023 15:42
@dashashifrina dashashifrina marked this pull request as ready for review October 25, 2023 21:24
@dashashifrina dashashifrina requested review from a team as code owners October 25, 2023 21:24
@dashashifrina dashashifrina requested a review from woodb October 25, 2023 21:25
datadog/resource_datadog_powerpack.go Show resolved Hide resolved
datadog/resource_datadog_powerpack.go Show resolved Hide resolved
datadog/resource_datadog_powerpack.go Outdated Show resolved Hide resolved
datadog/resource_datadog_powerpack.go Outdated Show resolved Hide resolved
datadog/resource_datadog_powerpack.go Show resolved Hide resolved
datadog/resource_datadog_powerpack.go Show resolved Hide resolved
woodb
woodb previously approved these changes Nov 2, 2023
Copy link

@woodb woodb left a comment

Choose a reason for hiding this comment

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

lgtm!

Base automatically changed from dasha.shifrina/powerpacks-pt-1 to master November 3, 2023 13:30
@skarimo skarimo dismissed stale reviews from woodb and buraizu November 3, 2023 13:30

The base branch was changed.

@dashashifrina dashashifrina requested review from a team as code owners November 13, 2023 18:40
@dashashifrina dashashifrina removed request for a team November 13, 2023 18:47
@nkzou nkzou merged commit 8a037a5 into master Nov 14, 2023
8 checks passed
@nkzou nkzou deleted the dasha.shifrina/powerpacks-pt-2 branch November 14, 2023 16:08
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