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.widget.timeseries_definition.request.query.slo_query.measure does not support bad_minutes #2646

Open
glungley opened this issue Nov 6, 2024 · 0 comments
Labels

Comments

@glungley
Copy link

glungley commented Nov 6, 2024

Datadog Terraform Provider Version

v3.46.0

Terraform Version

v1.8.5

What resources or data sources are affected?

resource_datadog_dashboard

Terraform Configuration Files

locals {
  slos = [ for name, x in module.slos : {
      name = name
      p95_slo_id = x.p95_slo_id
      p99_slo_id = x.p99_slo_id
  }]
}

resource "datadog_dashboard" "ordered_dashboard" {
  title       = "SLOs"
  layout_type = "ordered"

  widget {
    service_level_objective_definition {
      slo_id = module.all.p95_slo_id
      time_windows = ["month_to_date"]
      view_mode = "overall"
      view_type = "detail"
      show_error_budget = true
    }

    widget_layout {
      height = 2
      width  = 2
      x = 1
      y = 0
    }
  }

  widget {
    service_level_objective_definition {
      slo_id = module.all.p99_slo_id
      time_windows = ["month_to_date"]
      view_mode = "overall"
      view_type = "detail"
      show_error_budget = true
    }

    widget_layout {
      height = 2
      width  = 2
      x = 5
      y = 0
    }
  }

  widget {
    timeseries_definition {
      title = "p95 Latency Breaches"
      live_span = "month_to_date"

      request {
        display_type = "area"

        dynamic "formula" {
          for_each = { for i, x in local.slos : "query${i}" => x.name }

          content {
            alias = formula.value
            formula_expression = formula.key
          }
        }

        dynamic "query" {
          for_each = { for i, x in local.slos : "query${i}" => x.p95_slo_id }
          content {
            slo_query {
              name = query.key
              data_source = "slo"
              slo_id = query.value
              measure = "bad_minutes"
              slo_query_type = "time_slice"
            }
          }  
        }

        style {
          palette = "red"
        }
      }
    }

    widget_layout {
      height = 2
      width  = 4
      x = 0
      y = 2
    }
  }

  widget {
    timeseries_definition {
      title = "p99 Latency Breaches"
      live_span = "month_to_date"

      request {
        display_type = "area"

        dynamic "formula" {
          for_each = { for i, x in local.slos : "query${i}" => x.name }

          content {
            alias = formula.value
            formula_expression = formula.key
          }
        }

        dynamic "query" {
          for_each = { for i, x in local.slos : "query${i}" => x.p99_slo_id }
          content {
            slo_query {
              name = query.key
              data_source = "slo"
              slo_id = query.value
              measure = "bad_minutes"
              slo_query_type = "time_slice"
            }
          }  
        }

        style {
          palette = "red"
        }
      }
    }

    widget_layout {
      height = 2
      width  = 4
      x = 4
      y = 2
    }
  }

  widget {
    slo_list_definition {
      title = "p95 latency breakdown"

      request {
        query {
          query_string = "name:\"p95\" -name:\"all\""
          sort {
            column = "status.sli"
            order = "asc"
          }
        }
        request_type = "slo_list"
      }
    }

    widget_layout {
      height = 4
      width  = 4
      x = 0
      y = 4
    }
  }

  widget {
    slo_list_definition {
      title = "p99 latency breakdown"

      request {
        query {
          query_string = "name:\"p99\" -name:\"all\""
          sort {
            column = "status.sli"
            order = "asc"
          }
        }
        request_type = "slo_list"
      }
    }

    widget_layout {
      height = 4
      width  = 4
      x = 4
      y = 4
    }
  }
}

Relevant debug or panic output

Error: object contains unparsed element: map[data_source:slo group_mode:overall measure:bad_minutes name:query0 slo_id:0c80a6d0193f5bf6b006c35f28a53fde slo_query_type:time_slice]

  with datadog_dashboard.ordered_dashboard,
  on dashboard.tf line 9, in resource "datadog_dashboard" "ordered_dashboard":
   9: resource "datadog_dashboard" "ordered_dashboard" {

Expected Behavior

The provider should accept bad_minutes as an option to the measure field or gracefully adjust bad_events.

Actual Behavior

Setting measure to bad_minutes fails the provider's validation on the field. Setting it to bad_events passes validation and successfully deploys, but the graph is blank. Editing the graph in the UI, making no changes and saving it updates these fields to bad_minutes but causes subsequent plans to produce the error seen in the relevant debug/panic output.

Steps to Reproduce

  1. Plan the above configuration.
  2. Change bad_minutes to bad_events
  3. Plan & apply
  4. In the UI edit and save the graph making no changes
  5. Run terraform plan again

Important Factoids

no

References

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant