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] support for query table #2168

Merged

Conversation

dashashifrina
Copy link
Contributor

@dashashifrina dashashifrina commented Nov 1, 2023

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

Previous PR:

Changes

  • Add support for query_table
  • 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" "test_powerpack" {
  name         = "{{uniq}}"
  tags = ["tag:foo1"]
  description   = "Created using the Datadog provider in Terraform"
  template_variables {
    defaults = ["defaults"]
    name     = "datacenter"
  }
  widget {
    query_table_definition {
      title_size = "16"
      title = "system.cpu.user, system.load.1"
      title_align = "right"
      request {
      aggregator = "max"
      conditional_formats {
        palette = "white_on_green"
        value = 90
        comparator = "<"
      }
      conditional_formats {
        palette = "white_on_red"
        value = 90
        comparator = ">="
      }
      q = "avg:system.cpu.user{account:prod} by {service, team}"
      alias = "cpu user"
      limit = 25
      order = "desc"
      cell_display_mode = ["number"]
    }
      request {
        q = "avg:system.load.1{*} by {service, team}"
        aggregator = "last"
        conditional_formats {
          palette = "custom_bg"
          value = 50
          comparator = ">"
        }
        alias = "system load"
        cell_display_mode = ["number"]
      }
      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"
      }
      has_search_bar = "auto"
    }
}

  widget {
    query_table_definition {
      request {
        apm_stats_query {
        service = "service"
        env = "env"
        primary_tag = "tag:*"
        name = "name"
        row_type = "resource"
        }
      }
    has_search_bar = "never"
    }
  }
  widget {
    query_table_definition {
      request {
        formula {
          formula_expression = "query1"
          limit {
            count = 500
            order = "desc"
          }
          conditional_formats {
            palette = "white_on_green"
            value = 90
            comparator = "<"
          }
          conditional_formats {
            palette = "white_on_red"
            value = 90
            comparator = ">="
          }
        }
        query {
          metric_query {
          data_source = "metrics"
          query       = "avg:system.cpu.system{*} by {datacenter}"
          name        = "query1"
          aggregator  = "sum"
          }
        }
      }
    }
  }
  widget {
    query_table_definition {
      request {
        query {
          apm_dependency_stats_query {
            name           = "my-query"
            data_source    = "apm_dependency_stats"
            env            = "ci"
            service        = "cassandra"
            operation_name = "cassandra.query"
            resource_name  = "CREATE TABLE IF NOT EXISTS foobar"
            stat           = "avg_duration"
          }
        }
      }
    }
  }
}

@dashashifrina dashashifrina force-pushed the dasha.shifrina/powerpacks-pt-4 branch from fb1701a to be48f59 Compare November 1, 2023 03:03
@dashashifrina dashashifrina changed the title support for query table [datadog_powerpacks] support for query table Nov 2, 2023
@dashashifrina dashashifrina merged commit 021f70a into dasha.shifrina/powerpacks-pt-3 Nov 2, 2023
2 checks passed
@dashashifrina dashashifrina deleted the dasha.shifrina/powerpacks-pt-4 branch November 2, 2023 21:31
@dashashifrina dashashifrina restored the dasha.shifrina/powerpacks-pt-4 branch November 2, 2023 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant