Dashboard Conversion Seeing Error TypeError: array.forEach is not a function
Closed this issue · 4 comments
Describe the bug
Trying to convert a dashboard json to terraform is seeing a TypeError: array.forEach is not a function
To Reproduce
Try converting this dashboard
{
"title": "bpham-test",
"description": "",
"widgets": [
{
"id": 3383947803306764,
"definition": {
"title": "k8s metrics",
"type": "group",
"layout_type": "ordered",
"widgets": [
{
"id": 643181470432836,
"definition": {
"title": "CPU Usage per Node",
"title_size": "16",
"title_align": "left",
"type": "hostmap",
"requests": {
"fill": {
"q": "sum:kubernetes.cpu.usage.total{$cluster_project_id,$cluster} by {host}"
}
},
"no_metric_hosts": false,
"no_group_hosts": true,
"group": ["kube_metadata.node.label.cloud.google.com/gke-nodepool"],
"scope": ["$project_id", "$cluster"],
"style": { "palette": "YlOrRd", "palette_flip": false }
}
}
]
}
}
],
"template_variables": [
{ "name": "cluster_project_id", "default": "testporo", "prefix": "project" },
{ "name": "cluster", "default": "ucr-cluster", "prefix": "cluster_name" },
{ "name": "namespace", "default": "*", "prefix": "kube_namespace" },
{ "name": "subscription_project_id", "default": "cluster", "prefix": "project_id" }
],
"layout_type": "ordered",
"is_read_only": false,
"notify_list": [],
"id": "mue-kck-jmi"
}
Expected behavior
Conversion should work.
System info (please complete the following information):
- OS: Mac OS 11.2.2
- Browser Chrome
- Version 88.0.4324.192
Thanks for opening this, I'll take a look now!
@brianpham could you give me an example of the terraform code this should convert to? I've never seen json where the innermost requests
is an object (rather than an array) and I'm actually not sure what the conversion should be.
Thanks @laurmurclar.
This is an example of how it should look like based from the examples.
resource "datadog_dashboard" "ordered_dashboard" {
title = "Ordered Layout Dashboard"
description = "Created using the Datadog provider in Terraform"
layout_type = "ordered"
is_read_only = true
widget {
hostmap_definition {
request {
fill {
q = "avg:system.load.1{*} by {host}"
}
size {
q = "avg:memcache.uptime{*} by {host}"
}
}
node_type = "container"
group = ["host", "region"]
no_group_hosts = true
no_metric_hosts = true
scope = ["region:us-east-1"]
style {
palette = "yellow_to_green"
palette_flip = true
fill_min = "10"
fill_max = "20"
}
title = "Widget Title"
}
}
template_variable {
name = "var_1"
prefix = "host"
default = "aws"
}
template_variable {
name = "var_2"
prefix = "service_name"
default = "autoscaling"
}
template_variable_preset {
name = "preset_1"
template_variable {
name = "var_1"
value = "host.dc"
}
template_variable {
name = "var_2"
value = "my_service"
}
}
This should be fixed in the latest release 💃 I've submitted it to the Chrome & Firefox stores but it can take a few hours/days to get approved.
Feel free to open another issue if there are any problems with it. Thanks for this one!