terraformer icon indicating copy to clipboard operation
terraformer copied to clipboard

Terraformer imported Datadog dashboard not preserving order

Open weichuliu opened this issue 2 years ago • 4 comments

Hi, I tried to import Datadog dashboard using terraformer.

However, the imported .tf file doesn't seem to preserve either the group order or the widget order. So, if I apply the .tf, basically the dashboard graphs are randomly shuffled.

I am using Terraformer 0.8.2.0, and Datadog provider 3.11.0. Both the latest version.

Here is how to reproduce.

  • Create a dashboard randomly. I created one with two groups ("Group 3", then "Group 2") and 2 graphs per group, titled "4", "3" in Group 3; Titled "2", "1" in "Group 2".
{"title":"TestBoard","description":"## Title\n\nDescribe this dashboard. Add links to other dashboards, monitors, wikis,  and docs to help your teammates. Markdown is supported.\n\n- [This might link to a dashboard](#)\n- [This might link to a wiki](#)","widgets":[{"id":3162817219040794,"definition":{"title":"Group 3","type":"group","show_title":true,"layout_type":"ordered","widgets":[{"id":398899176012522,"definition":{"title":"4","title_size":"16","title_align":"left","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"response_format":"timeseries","queries":[{"name":"query1","data_source":"metrics","query":"avg:system.cpu.user{*}"}],"style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]},"layout":{"x":0,"y":0,"width":4,"height":2}},{"id":3549571517443056,"definition":{"title":"3","title_size":"16","title_align":"left","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"response_format":"timeseries","queries":[{"name":"query1","data_source":"metrics","query":"avg:system.cpu.user{*}"}],"style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]},"layout":{"x":4,"y":0,"width":4,"height":2}}]},"layout":{"x":0,"y":0,"width":12,"height":3}},{"id":8411657921683638,"definition":{"title":"Group 2","type":"group","show_title":true,"layout_type":"ordered","widgets":[{"id":7827610054614036,"definition":{"title":"2","title_size":"16","title_align":"left","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"response_format":"timeseries","queries":[{"name":"query1","data_source":"metrics","query":"avg:system.cpu.user{*}"}],"style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]},"layout":{"x":0,"y":0,"width":4,"height":2}},{"id":3118368310491542,"definition":{"title":"1","title_size":"16","title_align":"left","show_legend":true,"legend_layout":"auto","legend_columns":["avg","min","max","value","sum"],"time":{},"type":"timeseries","requests":[{"response_format":"timeseries","queries":[{"name":"query1","data_source":"metrics","query":"avg:system.cpu.user{*}"}],"style":{"palette":"dog_classic","line_type":"solid","line_width":"normal"},"display_type":"line"}]},"layout":{"x":4,"y":0,"width":4,"height":2}}]},"layout":{"x":0,"y":3,"width":12,"height":3}}],"template_variables":[],"layout_type":"ordered","is_read_only":false,"notify_list":[],"reflow_type":"fixed","id":"imt-6r3-tza"}
  • Import the dashboard many times:
mkdir -p /tmp/testboard/{1..10}
for i in /tmp/testboard/{1..10}; do terraformer import datadog --resources=dashboard --filter=dashboard=imt-6r3-tza --path-output=$i; done
  • Check the dashboard.tf, it is expected to be [{Group 3: 4, 3}, {Group 2: 2, 1}]. However this is what I got:
----------/tmp/testboard/1
  title        = "TestBoard"
      title       = "Group 2"
          title       = "1"
          title       = "2"
      title       = "Group 3"
          title       = "4"
          title       = "3"
----------/tmp/testboard/2
  title        = "TestBoard"
      title       = "Group 2"
          title       = "1"
          title       = "2"
      title       = "Group 3"
          title       = "3"
          title       = "4"
----------/tmp/testboard/3
  title        = "TestBoard"
      title       = "Group 2"
          title       = "2"
          title       = "1"
      title       = "Group 3"
          title       = "3"
          title       = "4"
----------/tmp/testboard/4
  title        = "TestBoard"
      title       = "Group 2"
          title       = "1"
          title       = "2"
      title       = "Group 3"
          title       = "4"
          title       = "3"
----------/tmp/testboard/5
  title        = "TestBoard"
      title       = "Group 2"
          title       = "1"
          title       = "2"
      title       = "Group 3"
          title       = "4"
          title       = "3"
----------/tmp/testboard/6
  title        = "TestBoard"
      title       = "Group 2"
          title       = "1"
          title       = "2"
      title       = "Group 3"
          title       = "4"
          title       = "3"
----------/tmp/testboard/7
  title        = "TestBoard"
      title       = "Group 2"
          title       = "2"
          title       = "1"
      title       = "Group 3"
          title       = "3"
          title       = "4"
----------/tmp/testboard/8
  title        = "TestBoard"
      title       = "Group 2"
          title       = "2"
          title       = "1"
      title       = "Group 3"
          title       = "4"
          title       = "3"
----------/tmp/testboard/9
  title        = "TestBoard"
      title       = "Group 2"
          title       = "1"
          title       = "2"
      title       = "Group 3"
          title       = "3"
          title       = "4"
----------/tmp/testboard/10
  title        = "TestBoard"
      title       = "Group 2"
          title       = "2"
          title       = "1"
      title       = "Group 3"
          title       = "3"
          title       = "4"

Looks like Group level is sorted by name, and the graph order is undetermined everytime when import.

weichuliu avatar May 19 '22 09:05 weichuliu

By the way, this is introduced in v0.8.19, because v0.8.18 works fine.

weichuliu avatar May 20 '22 06:05 weichuliu

I think this causes by the same reason in https://github.com/GoogleCloudPlatform/terraformer/issues/1316

chinuy avatar May 27 '22 14:05 chinuy

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 27 '22 02:07 github-actions[bot]

~This issue must be resolved. Latest version (v0.8.19) is completely unusable for datadog dashboard because of this problem.~

Sorry, I have not checked this problem exists in latest (v0.8.21).

ikuwow avatar Jul 27 '22 02:07 ikuwow

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Sep 26 '22 02:09 github-actions[bot]

This issue still exists in v0.8.22.

CostinTanasoiu avatar Sep 29 '22 15:09 CostinTanasoiu

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Nov 30 '22 02:11 github-actions[bot]

Hey, is there any workaround to go over this issue? the last version doesn't look stable when it comes to import Datadog dashboards

bshbair avatar Dec 02 '22 15:12 bshbair

@bshbair I've resorted to exporting my DataDog dashboards as JSON, and then providing that JSON to a new datadog_dashboard_json resource in Terraform. I do suggest saving your JSON file separately and loading that up in the resource using the file(...) function:

resource "datadog_dashboard_json" "example_dash" {
  dashboard = file("${path.module}/dashboard_templates/example_dash.json")
}

CostinTanasoiu avatar Dec 02 '22 17:12 CostinTanasoiu

Thanks @CostinTanasoiu , I think that solves the problem for now

bshbair avatar Dec 06 '22 14:12 bshbair

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 05 '23 02:02 github-actions[bot]

Any updates?

ikuwow avatar Feb 05 '23 04:02 ikuwow

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 12 '23 02:06 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Jun 20 '23 01:06 github-actions[bot]