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 and treemap #2170

Conversation

dashashifrina
Copy link
Contributor

@dashashifrina dashashifrina commented Nov 2, 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
    • treemap
  • 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"
          }
        }
      }
    }
  }
  widget {
    treemap_definition {
      request {
        formula {
          formula_expression = "my_query_1 + my_query_2"
          alias              = "my ff query"
        }
        query {
          metric_query {
            data_source = "metrics"
            query       = "avg:system.cpu.user{foo:bar} by {env}"
            name        = "my_query_1"
            aggregator  = "sum"
          }
        }
      }
    }
  }
}

@dashashifrina dashashifrina force-pushed the dasha.shifrina/powerpacks-pt-3 branch from cdb0fa4 to f529fff Compare November 14, 2023 17:19
@dashashifrina dashashifrina changed the title [datadog_powerpacks] support for query table [datadog_powerpacks] support for query table and treemap Nov 16, 2023
@nkzou nkzou closed this Dec 11, 2023
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.

2 participants