From 3ee2eaa6348b3ee87634f9e37a11bfaa07bd9828 Mon Sep 17 00:00:00 2001 From: Dan Hurwit Date: Mon, 12 Feb 2024 14:17:37 -0500 Subject: [PATCH] Add event query ids (#207) * add eventqueries * add test * fmt * add project name * update function * Test * remove * why? * acceptance tests * acceptance tests * run tfdocs step * hey its me * branch * branch * maybe * origin * Actual checkout * correct email * push * origin * origin * origin2 * different * test * test * test * rever * Revert "rever" This reverts commit 79a62c649668d4dbb1c9037d6dd735fc0123c969. * Reapply "rever" This reverts commit 5cdfcbc1ddc140b829fb972838aa65e31411eb70. * whoops * Revert "whoops" This reverts commit 318f27171cc559b1562c44dbda602393a1e0eded. * test * view remote * view remote * view remote * view remote * v3 * this? * creds * v3 * organize * Author * switch * switch * fetch depth 0 * don't persist creds * need that * version * added terraform docs --------- Co-authored-by: danhurwit --- .github/workflows/pr.yml | 34 ++-- .go-version | 3 +- client/event_query.go | 87 +++++++++++ client/metric_dashboards.go | 2 + docs/resources/dashboard.md | 1 + docs/resources/event_query.md | 28 ++++ docs/resources/metric_dashboard.md | 1 + lightstep/provider.go | 1 + lightstep/resource_event_query.go | 163 ++++++++++++++++++++ lightstep/resource_event_query_test.go | 109 +++++++++++++ lightstep/resource_metric_dashboard.go | 23 ++- lightstep/resource_metric_dashboard_test.go | 55 +++++++ 12 files changed, 488 insertions(+), 19 deletions(-) create mode 100644 client/event_query.go create mode 100644 docs/resources/event_query.md create mode 100644 lightstep/resource_event_query.go create mode 100644 lightstep/resource_event_query_test.go diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 97a5af43..6d87731d 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -14,7 +14,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} persist-credentials: false @@ -31,30 +31,38 @@ jobs: name: Run tfplugindocs runs-on: ubuntu-latest permissions: - contents: read - + contents: write steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} - persist-credentials: false - + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 - uses: actions/setup-go@v4 with: go-version: '1.20.5' # tfplugindocs requires go >= 1.18 - - name: Setup tfplugindocs run: | cd /tmp curl -L -o tfplugindocs.zip https://github.com/hashicorp/terraform-plugin-docs/releases/download/v0.15.0/tfplugindocs_0.15.0_linux_amd64.zip unzip tfplugindocs.zip chmod +x tfplugindocs - - - name: Compare generated files with checked in files + - name: Generate tf docs + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | rm -r docs /tmp/tfplugindocs - git diff --stat --exit-code ./docs + - name: Commit And Push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --local user.email "${{ github.actor }}@users.noreply.github.com" + git config --local user.name ${{ github.actor }} + git add . + git commit -m "added terraform docs" + git push + terraform_lint: name: Run terraform-lint @@ -63,7 +71,7 @@ jobs: contents: read steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} persist-credentials: false @@ -87,7 +95,7 @@ jobs: go-version: '1.20.5' - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup terraform CLI uses: hashicorp/setup-terraform@v1 @@ -116,7 +124,7 @@ jobs: go-version: '1.20.5' - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup terraform CLI uses: hashicorp/setup-terraform@v1 diff --git a/.go-version b/.go-version index 82e24bf2..9a5d24e6 100644 --- a/.go-version +++ b/.go-version @@ -1 +1,2 @@ -1.90.0 +1.91.0 + diff --git a/client/event_query.go b/client/event_query.go new file mode 100644 index 00000000..2614c074 --- /dev/null +++ b/client/event_query.go @@ -0,0 +1,87 @@ +package client + +import ( + "context" + "encoding/json" + "fmt" + "net/http" +) + +type EventQueryAttributes struct { + ID string `json:"id"` + Name string `json:"name"` + QueryString string `json:"query_string"` + Source string `json:"source"` + Type string `json:"type"` +} + +type WireEventQueryAttributes struct { + Attributes EventQueryAttributes `json:"attributes"` +} + +func (c *Client) GetEventQuery(ctx context.Context, projectName string, eventQueryID string) (*EventQueryAttributes, error) { + var ( + event *WireEventQueryAttributes + resp Envelope + ) + + if err := c.CallAPI(ctx, "GET", fmt.Sprintf("projects/%v/event_queries/%v", + projectName, eventQueryID), nil, &resp); err != nil { + return nil, err + } + if err := json.Unmarshal(resp.Data, &event); err != nil { + return nil, err + } + return &event.Attributes, nil +} + +func (c *Client) CreateEventQuery(ctx context.Context, projectName string, attributes EventQueryAttributes) (*EventQueryAttributes, error) { + var ( + event *EventQueryAttributes + resp Envelope + ) + + body := WireEventQueryAttributes{Attributes: attributes} + bytes, err := json.Marshal(body) + if err != nil { + return event, err + } + if err := c.CallAPI(ctx, "POST", + fmt.Sprintf("projects/%v/event_queries", projectName), Envelope{Data: bytes}, &resp); err != nil { + return nil, err + } + err = json.Unmarshal(resp.Data, &event) + return event, err +} + +func (c *Client) UpdateEventQuery(ctx context.Context, projectName string, eventQueryID string, attributes EventQueryAttributes) (*EventQueryAttributes, error) { + var ( + event *EventQueryAttributes + resp Envelope + ) + + bytes, err := json.Marshal(attributes) + if err != nil { + return event, err + } + if err := c.CallAPI(ctx, "PUT", + fmt.Sprintf("projects/%v/event_queries/%v", eventQueryID, projectName), bytes, &resp); err != nil { + return nil, err + } + err = json.Unmarshal(resp.Data, &event) + return event, err +} + +func (c *Client) DeleteEventQuery(ctx context.Context, projectName string, eventQueryID string) error { + err := c.CallAPI(ctx, "DELETE", + fmt.Sprintf("projects/%v/event_queries/%v", projectName, eventQueryID), + nil, + nil) + if err != nil { + apiClientError, ok := err.(APIResponseCarrier) + if !ok || apiClientError.GetStatusCode() != http.StatusNoContent { + return err + } + } + return nil +} diff --git a/client/metric_dashboards.go b/client/metric_dashboards.go index 038a747e..b6dce751 100644 --- a/client/metric_dashboards.go +++ b/client/metric_dashboards.go @@ -21,6 +21,7 @@ type UnifiedDashboardAttributes struct { Groups []UnifiedGroup `json:"groups"` Labels []Label `json:"labels"` TemplateVariables []TemplateVariable `json:"template_variables"` + EventQueryIDs []string `json:"event_query_ids"` } type UnifiedGroup struct { @@ -112,6 +113,7 @@ func (c *Client) CreateUnifiedDashboard( Groups: dashboard.Attributes.Groups, Labels: dashboard.Attributes.Labels, TemplateVariables: dashboard.Attributes.TemplateVariables, + EventQueryIDs: dashboard.Attributes.EventQueryIDs, }, }) diff --git a/docs/resources/dashboard.md b/docs/resources/dashboard.md index bcf011f7..c19aacbe 100644 --- a/docs/resources/dashboard.md +++ b/docs/resources/dashboard.md @@ -67,6 +67,7 @@ resource "lightstep_dashboard" "customer_charges" { - `chart` (Block Set) (see [below for nested schema](#nestedblock--chart)) - `dashboard_description` (String) +- `event_query_ids` (Set of String) IDs of the event queries to display on this dashboard - `group` (Block Set) (see [below for nested schema](#nestedblock--group)) - `label` (Block Set) Labels can be key/value pairs or standalone values. (see [below for nested schema](#nestedblock--label)) - `template_variable` (Block Set) Variable to be used in dashboard queries for dynamically filtering telemetry data (see [below for nested schema](#nestedblock--template_variable)) diff --git a/docs/resources/event_query.md b/docs/resources/event_query.md new file mode 100644 index 00000000..8960acdc --- /dev/null +++ b/docs/resources/event_query.md @@ -0,0 +1,28 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "lightstep_event_query Resource - terraform-provider-lightstep" +subcategory: "" +description: |- + +--- + +# lightstep_event_query (Resource) + + + + + + +## Schema + +### Required + +- `name` (String) +- `project_name` (String) Lightstep project name +- `query_string` (String) +- `source` (String) +- `type` (String) + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/metric_dashboard.md b/docs/resources/metric_dashboard.md index b0efc334..60f08fe3 100644 --- a/docs/resources/metric_dashboard.md +++ b/docs/resources/metric_dashboard.md @@ -90,6 +90,7 @@ resource "lightstep_metric_dashboard" "customer_charges" { - `chart` (Block Set) (see [below for nested schema](#nestedblock--chart)) - `dashboard_description` (String) +- `event_query_ids` (Set of String) IDs of the event queries to display on this dashboard - `group` (Block Set) (see [below for nested schema](#nestedblock--group)) - `label` (Block Set) Labels can be key/value pairs or standalone values. (see [below for nested schema](#nestedblock--label)) - `template_variable` (Block Set) Variable to be used in dashboard queries for dynamically filtering telemetry data (see [below for nested schema](#nestedblock--template_variable)) diff --git a/lightstep/provider.go b/lightstep/provider.go index bdba21f9..d6a856bb 100644 --- a/lightstep/provider.go +++ b/lightstep/provider.go @@ -71,6 +71,7 @@ func Provider() *schema.Provider { "lightstep_user_role_binding": resourceUserRoleBinding(), "lightstep_inferred_service_rule": resourceInferredServiceRule(), "lightstep_saml_group_mappings": resourceSAMLGroupMappings(), + "lightstep_event_query": resourceEventQuery(), }, DataSourcesMap: map[string]*schema.Resource{ diff --git a/lightstep/resource_event_query.go b/lightstep/resource_event_query.go new file mode 100644 index 00000000..c4ad2136 --- /dev/null +++ b/lightstep/resource_event_query.go @@ -0,0 +1,163 @@ +package lightstep + +import ( + "context" + "errors" + "fmt" + "net/http" + "strings" + + "github.com/lightstep/terraform-provider-lightstep/client" + + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceEventQuery() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceEventQueryCreate, + ReadContext: resourceEventQueryRead, + UpdateContext: resourceEventQueryUpdate, + DeleteContext: resourceEventQueryDelete, + Importer: &schema.ResourceImporter{ + StateContext: resourceEventQueryImport, + }, + Schema: map[string]*schema.Schema{ + "project_name": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + Description: "Lightstep project name", + }, + "name": { + Type: schema.TypeString, + Required: true, + }, + "source": { + Type: schema.TypeString, + Required: true, + }, + "query_string": { + Type: schema.TypeString, + Required: true, + }, + "type": { + Type: schema.TypeString, + Required: true, + }, + }, + } +} + +func resourceEventQueryRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + c := m.(*client.Client) + + eq, err := c.GetEventQuery(ctx, d.Get("project_name").(string), d.Id()) + if err != nil { + apiErr, ok := err.(client.APIResponseCarrier) + if !ok { + return diag.FromErr(fmt.Errorf("failed to get event query: %v", err)) + } + if apiErr.GetStatusCode() == http.StatusNotFound { + d.SetId("") + return diags + } + return diag.FromErr(fmt.Errorf("failed to get event query: %v", apiErr)) + } + + if err := d.Set("name", eq.Name); err != nil { + return diag.FromErr(fmt.Errorf("unable to set query name: %v", err)) + } + if err := d.Set("type", eq.Type); err != nil { + return diag.FromErr(fmt.Errorf("unable to set query type: %v", err)) + } + if err := d.Set("query_string", eq.QueryString); err != nil { + return diag.FromErr(fmt.Errorf("unable to set query string: %v", err)) + } + if err := d.Set("source", eq.Source); err != nil { + return diag.FromErr(fmt.Errorf("unable to set query string: %v", err)) + } + + return diags +} + +func resourceEventQueryCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + c := m.(*client.Client) + + attrs := client.EventQueryAttributes{ + Type: d.Get("type").(string), + Name: d.Get("name").(string), + Source: d.Get("source").(string), + QueryString: d.Get("query_string").(string), + } + eq, err := c.CreateEventQuery(ctx, d.Get("project_name").(string), attrs) + if err != nil { + return diag.FromErr(fmt.Errorf("failed to create event query %v: %v", attrs.Name, err)) + } + + d.SetId(eq.ID) + return resourceEventQueryRead(ctx, d, m) +} + +func resourceEventQueryImport(ctx context.Context, d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) { + c := m.(*client.Client) + + ids := strings.Split(d.Id(), ".") + if len(ids) != 2 { + return []*schema.ResourceData{}, errors.New("error importing event query. Expecting an ID formed as '.'") + } + + project, id := ids[0], ids[1] + eq, err := c.GetEventQuery(ctx, project, id) + if err != nil { + return []*schema.ResourceData{}, fmt.Errorf("failed to get event query: %v", err) + } + + d.SetId(eq.ID) + if err := d.Set("project_name", project); err != nil { + return []*schema.ResourceData{}, fmt.Errorf("unable to set project_name resource field: %v", err) + } + if err := d.Set("name", eq.Name); err != nil { + return nil, fmt.Errorf("unable to set query name: %v", err) + } + if err := d.Set("type", eq.Type); err != nil { + return nil, fmt.Errorf("unable to set query type: %v", err) + } + if err := d.Set("query_string", eq.QueryString); err != nil { + return nil, fmt.Errorf("unable to set query string: %v", err) + } + if err := d.Set("source", eq.Source); err != nil { + return nil, fmt.Errorf("unable to set query string: %v", err) + } + return []*schema.ResourceData{d}, nil +} + +func resourceEventQueryUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + c := m.(*client.Client) + + attrs := client.EventQueryAttributes{ + Type: d.Get("type").(string), + Name: d.Get("name").(string), + Source: d.Get("source").(string), + QueryString: d.Get("query_string").(string), + } + eq, err := c.UpdateEventQuery(ctx, d.Get("project_name").(string), d.Id(), attrs) + if err != nil { + return diag.FromErr(fmt.Errorf("failed to create event query %v: %v", attrs.Name, err)) + } + + d.SetId(eq.ID) + return resourceEventQueryRead(ctx, d, m) +} + +func resourceEventQueryDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { + var diags diag.Diagnostics + + client := m.(*client.Client) + if err := client.DeleteEventQuery(ctx, d.Get("project_name").(string), d.Id()); err != nil { + return diag.FromErr(fmt.Errorf("failed to delete event query: %v", err)) + } + + return diags +} diff --git a/lightstep/resource_event_query_test.go b/lightstep/resource_event_query_test.go new file mode 100644 index 00000000..aa6bf410 --- /dev/null +++ b/lightstep/resource_event_query_test.go @@ -0,0 +1,109 @@ +package lightstep + +import ( + "context" + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/lightstep/terraform-provider-lightstep/client" + "testing" +) + +func TestAccEventQuery(t *testing.T) { + var eventQuery client.EventQueryAttributes + + eventQueryConfig := ` +resource "lightstep_event_query" "terraform" { + project_name = "` + testProject + `" + name = "test-name" + type = "test-type" + source = "test-source" + query_string = "logs" +} +` + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccEventQueryDestroy, + Steps: []resource.TestStep{ + { + Config: eventQueryConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckEventQueryExists("lightstep_event_query.terraform", &eventQuery), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "name", "test-name"), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "type", "test-type"), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "source", "test-source"), + resource.TestCheckResourceAttr("lightstep_event_query.terraform", "query_string", "logs"), + ), + }, + }, + }) + +} + +func TestAccEventQueryImport(t *testing.T) { + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: ` +resource "lightstep_event_query" "imported" { + project_name = "` + testProject + `" + name = "test-name-imported" + type = "test-type-imported" + source = "test-source-imported" + query_string = "logs | filter body == imported" +} +`, + }, + { + ResourceName: "lightstep_event_query.imported", + ImportState: true, + ImportStateVerify: true, + ImportStateIdPrefix: fmt.Sprintf("%s.", testProject), + }, + }, + }) +} + +func testAccCheckEventQueryExists(resourceName string, attrs *client.EventQueryAttributes) resource.TestCheckFunc { + return func(s *terraform.State) error { + // get event from TF state + tfEvent, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("not found: %s", resourceName) + } + + if tfEvent.Primary.ID == "" { + return fmt.Errorf("id is not set") + } + + // get event from LS + client := testAccProvider.Meta().(*client.Client) + eq, err := client.GetEventQuery(context.Background(), testProject, tfEvent.Primary.ID) + if err != nil { + return err + } + + attrs = eq + return nil + } +} + +func testAccEventQueryDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*client.Client) + for _, r := range s.RootModule().Resources { + if r.Type != "lightstep_event_query" { + continue + } + + d, err := conn.GetEventQuery(context.Background(), testProject, r.Primary.ID) + if err == nil { + if d.ID == r.Primary.ID { + return fmt.Errorf("event query with ID (%v) still exists", r.Primary.ID) + } + } + } + return nil +} diff --git a/lightstep/resource_metric_dashboard.go b/lightstep/resource_metric_dashboard.go index 27fd119c..631ecfd9 100644 --- a/lightstep/resource_metric_dashboard.go +++ b/lightstep/resource_metric_dashboard.go @@ -94,6 +94,12 @@ func resourceUnifiedDashboard(chartSchemaType ChartSchemaType) *schema.Resource }, Description: "Variable to be used in dashboard queries for dynamically filtering telemetry data", }, + "event_query_ids": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Schema{Type: schema.TypeString}, + Description: "IDs of the event queries to display on this dashboard", + }, }, } } @@ -455,12 +461,16 @@ func getUnifiedDashboardAttributesFromResource(d *schema.ResourceData) (*client. templateVariableSet := d.Get("template_variable").(*schema.Set) templateVariables := buildTemplateVariables(templateVariableSet.List()) + eventQueriesSet := d.Get("event_query_ids").(*schema.Set) + eventQueries := buildStringSlice(eventQueriesSet.List()) + attributes := &client.UnifiedDashboardAttributes{ Name: d.Get("dashboard_name").(string), Description: d.Get("dashboard_description").(string), Groups: groups, Labels: labels, TemplateVariables: templateVariables, + EventQueryIDs: eventQueries, } return attributes, hasLegacyChartsIn, nil @@ -619,7 +629,7 @@ func buildTemplateVariables(templateVariablesIn []interface{}) []client.Template tvMap := tv.(map[string]interface{}) name := tvMap["name"].(string) suggestionAttributeKey := tvMap["suggestion_attribute_key"].(string) - defaultValues := buildDefaultValues(tvMap["default_values"].([]interface{})) + defaultValues := buildStringSlice(tvMap["default_values"].([]interface{})) newTemplateVariables = append(newTemplateVariables, client.TemplateVariable{ Name: name, @@ -630,12 +640,12 @@ func buildTemplateVariables(templateVariablesIn []interface{}) []client.Template return newTemplateVariables } -func buildDefaultValues(valuesIn []interface{}) []string { - defaultValues := make([]string, 0, len(valuesIn)) +func buildStringSlice(valuesIn []interface{}) []string { + vals := make([]string, 0, len(valuesIn)) for _, v := range valuesIn { - defaultValues = append(defaultValues, v.(string)) + vals = append(vals, v.(string)) } - return defaultValues + return vals } func (p *resourceUnifiedDashboardImp) setResourceDataFromUnifiedDashboard(project string, dash client.UnifiedDashboard, d *schema.ResourceData, hasLegacyChartsIn bool) error { @@ -709,6 +719,9 @@ func (p *resourceUnifiedDashboardImp) setResourceDataFromUnifiedDashboard(projec if err := d.Set("template_variable", templateVariables); err != nil { return fmt.Errorf("unable to set template variables resource field: %v", err) } + if err := d.Set("event_query_ids", dash.Attributes.EventQueryIDs); err != nil { + return fmt.Errorf("unable to set event_query_ids resource field: %v", err) + } return nil } diff --git a/lightstep/resource_metric_dashboard_test.go b/lightstep/resource_metric_dashboard_test.go index d7fc8d4b..55e78620 100644 --- a/lightstep/resource_metric_dashboard_test.go +++ b/lightstep/resource_metric_dashboard_test.go @@ -464,6 +464,61 @@ resource "lightstep_metric_dashboard" "test" { }) } +func TestAccDashboardEventQueries(t *testing.T) { + var dashboard client.UnifiedDashboard + var eventQuery client.EventQueryAttributes + + eventQueryConfig := ` +resource "lightstep_event_query" "terraform" { + project_name = "` + testProject + `" + name = "test-name" + type = "test-type" + source = "test-source" + query_string = "logs" +} +` + dashboardConfig := ` +resource "lightstep_metric_dashboard" "test" { + project_name = "` + testProject + `" + dashboard_name = "Acceptance Test Dashboard (TestAccDashboardServiceHealthPanel)" + dashboard_description = "Dashboard to test the service health panel" + event_query_ids = [lightstep_event_query.terraform.id] +} +` + updatedDashboardConfig := ` +resource "lightstep_metric_dashboard" "test" { + project_name = "` + testProject + `" + dashboard_name = "Acceptance Test Dashboard (TestAccDashboardServiceHealthPanel)" + dashboard_description = "Dashboard to test the service health panel" + event_query_ids = [] +} +` + resourceName := "lightstep_metric_dashboard.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + // Create the initial dashboard with a list of event_query_ids + Config: dashboardConfig + "\n" + eventQueryConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckEventQueryExists("lightstep_event_query.terraform", &eventQuery), + testAccCheckMetricDashboardExists(resourceName, &dashboard), + resource.TestCheckResourceAttr(resourceName, "event_query_ids.#", "1"), + ), + }, + { + // Updated config will contain the new metric and chart name + Config: updatedDashboardConfig + "\n" + eventQueryConfig, + Check: resource.ComposeTestCheckFunc( + testAccCheckMetricDashboardExists(resourceName, &dashboard), + resource.TestCheckResourceAttr(resourceName, "event_query_ids.#", "0"), + ), + }, + }, + }) +} + func TestAccDashboardAlertsListPanel(t *testing.T) { var dashboard client.UnifiedDashboard