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

Terraform Dashboard update to add account_ids when present in json input. #1542

Open
lukasleung opened this issue Dec 29, 2023 · 0 comments
Open

Comments

@lukasleung
Copy link

Feature Description

New Relic Dashboard JSON output occasionally outputs with multiple accountIds under the nrqlQueries object.
I have been unable to locate this in their docs, but have observed with some of our automation tooling this happening.

Sample json dashboard: (dashboard.json)

{
  "name": "My Dashboard",
  "description": "My Description",
  "permissions": "PUBLIC_READ_WRITE",
  "pages": [
    {
      "name": "My first page",
      "description": null,
      "widgets": [
        {
          "title": "My first tile",
          "layout": {
            "column": 1,
            "row": 1,
            "width": 4,
            "height": 4
          },
          "linkedEntityGuids": [
            "some_guid"
          ],
          "visualization": {
            "id": "viz.pie"
          },
          "rawConfiguration": {
            "facet": {
              "showOtherSeries": true
            },
            "legend": {
              "enabled": true
            },
            "nrqlQueries": [
              {
                "accountIds": [
                  1234567
                ],
                "query": "FROM Metric SELECT count(*)\nWHERE app = 'my_app' FACET some_attribute LIMIT 20"
              }
            ],
            "platformOptions": {
              "ignoreTimeRange": false
            }
          }
        },
        {
          "title": "My second tile",
          "layout": {
            "column": 1,
            "row": 5,
            "width": 4,
            "height": 4
          },
          "linkedEntityGuids": null,
          "visualization": {
            "id": "viz.pie"
          },
          "rawConfiguration": {
            "nrqlQueries": [
              {
                "accountId": 1234567,
                "query": "FROM Metric SELECT count(*)\nWHERE app = 'my_app' FACET some_attribute LIMIT 20"
              }
            ]
          }
        }
      ]
    }
  ],
  "variables": []
}

Executing newrelic-cli (version 0.78.1)

newrelic utils terraform dashboard --file dashboard.json --label test_dashboard --out dashboard.tf

Sample Terraform: (dashboard.tf)

resource "newrelic_one_dashboard" "test_dashboard" {
  name = "My Dashboard"
  description = "My Description"
  permissions = "public_read_write"

  page {
    name = "My first page"

    widget_pie {
      title = "My first tile"
      row = 1
      column = 1
      height = 4
      width = 4

      nrql_query {
        query = <<EOT
FROM Metric SELECT count(*)
WHERE app = 'my_app' FACET some_attribute LIMIT 20
EOT
      }
      facet_show_other_series = true
      legend_enabled = true
      ignore_time_range = false
      y_axis_left_min = 0
      y_axis_left_max = 0

      null_values {
        null_value = ""
      }

      units {
        unit = ""
      }

      colors {
        color = ""
      }
    }

    widget_pie {
      title = "My second tile"
      row = 5
      column = 1
      height = 4
      width = 4

      nrql_query {
        account_id = 1234567
        query = <<EOT
FROM Metric SELECT count(*)
WHERE app = 'my_app' FACET some_attribute LIMIT 20
EOT
      }
      facet_show_other_series = false
      legend_enabled = false
      ignore_time_range = false
      y_axis_left_min = 0
      y_axis_left_max = 0

      null_values {
        null_value = ""
      }

      units {
        unit = ""
      }

      colors {
        color = ""
      }
    }
  }
}

Note: there is a missing account_id/account_ids attribute in the "My first tile" nrql_query block.

I see this attribute is not in the DashboardWidgetNRQLQuery struct which I suspect is the place to fix.

Describe Alternatives

  • Massage the json before giving it to the tool.

Additional context

From the terraform docs (provider version 3.28.1), it is not clear if account_ids is supported for the Nested nrql_query blocks.

Screenshot 2023-12-29 at 11 15 50 AM

There is no explicit callout in the section, though there is mention in the Example Usage: Create a New Relic One Dashboard section:

Screenshot 2023-12-29 at 11 12 41 AM

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

No branches or pull requests

1 participant