Closed mason-jones-ck closed 1 year ago
This is a good argument for use of the Raw Configuration for widgets, which is in the API but not implemented.
➕ We are facing same issue when I tried to use newrelic_one_dashboard_raw resource and dynamically create widgets
dashboard.tf
locals {
l_newrelic_dashboard = {
for obj in var.newrelic_dashboard : obj.title => merge(var.newrelic_dashboard_defaults, obj)
}
}
resource "newrelic_one_dashboard_raw" "newrelic_service_dashboard_dynamic" {
for_each = local.l_newrelic_dashboard
name = each.value.title
page{
name = each.value.title
dynamic "widget" {
for_each = try(each.value["widget"], [])
title = widget.value.title
visualization_id = widget.value.visualization_id
column = widget.value.column
row = widget.value.row
height = widget.value.height
width = widget.value.width
configuration = <<EOT
{
"nrqlQueries": [
{
"query": widget.value.nrql
}
]
}
EOT
}
}
}
variables.tf
#---------------------------------------------------
# newrelic Overview Dashboard for Services
#---------------------------------------------------
variable "newrelic_dashboard" {
description = "overview dashboard for multiple services"
type = any
}
#------------------------------------------------------------------------
# newrelic Overview Dashboard for Services defaults/required
#------------------------------------------------------------------------
variable "newrelic_dashboard_defaults" {
type = object({
name = string,
page = object({
name = string,
widget = list(object({
title = string,
visualization_id = string,
row = number,
column = number,
height = number,
width = number,
configuration = object({
nrqlQueries = list(object({
query = string
}))
})
})
)
})
})
default = {
"name" = "Test-dashboard",
"page" = {
"name" = "Test dashboard",
"widget" = [
{
"title" = "",
"visualization_id" = "",
"nrql" = "",
"row" = 1,
"column" = 1,
"height" = 1,
"width" = 1,
"configuration" ={
"nrqlQueries": [
{
"query": ""
}
]
}
}
]
}
}
}
terragrunt.hcl
newrelic_dashboard = [
{
"name" = "Overview Dashboard"
"page" = {
"name" = "Overview Dashboard page 1"
"widget" = [
{
"title" = "[SB]Throughput (rpm)"
"visualization_id" = "facet_bar_chart"
"column" = 1
"row" = 1
"height" = 4
"width" = 4
"notes" = "rpm per endpoint"
"configuration" = {
"nrqlQueries" = [
{
"query" = "SELECT rate(count(apm.service.transaction.duration), 1 minute) as 'requests per min' FROM Metric WHERE appName='sandbox_service' AND transactionName!='WebTransaction/SpringController/health-shallow (GET)' SINCE 1 week AGO UNTIL now FACET `transactionName` "
}
]
}
}
]
}
}
]
Hey guys! Anyone managed to fix or bypass this error?
Looking for a fix too!
Hi all
We've added support for dashboard json in latest release: https://github.com/newrelic/terraform-provider-newrelic/discussions/2044
I think this might be a workaround for this particular use-case.
Thoughts?
We haven’t heard back from you in a long time so we will close the ticket. If you feel this is still a valid request or bug, feel free to create a new issue.
New Relic
provider
:Affected resources:
newrelic_one_dashboard
Configuration of the resources:
Basic main.tf we have been using:
Module tf:
Current behavior:
We have been using the older
newrelic_dashboard
resource, as shown. This has allowed us to create a module with some basic widgets, and then allow the including Terraform to pass in an array of widgets. These are then inserted into the dashboard by the module.With the newer
newrelic_one_dashboard
, because every widget is a different block type, this is no longer possible.Expected behavior:
We need a way to be able to include an arbitrary number of widgets dynamically by passing them in to a module.