Skip to content

Instantly share code, notes, and snippets.

@drewgillson
Created May 29, 2019 16:14
Show Gist options
  • Save drewgillson/8ae0b4a428c671c33da04398c03af282 to your computer and use it in GitHub Desktop.
Save drewgillson/8ae0b4a428c671c33da04398c03af282 to your computer and use it in GitHub Desktop.

dashboard cat

The dashboard cat command is used to output the json that describes the dashboard.

$ gzr dashboard cat 192 --host foo.bar.mycompany.com
JSON data for dashboard

The output document can be very long. Usually one will use the switch --dir DIRECTORY to save to a file. The file will be named Dashboard_{DASHBOARD_ID}_{DASHBOARD_TITLE}.json.

The --transform FILE switch can be used to update the output document. This is useful to automatically perform tasks when promoting dashboards to upper environments, such as adding header or footer text tiles, replacing model or explore names, or updating filter expressions. The FILE parameter accepts a fully-qualified path to a JSON file describing the transformations to apply.

$ gzr dashboard cat 192 --host foo.bar.mycompany.com --transform path/to/transforms.json
JSON data for dashboard modified by any transformations expressed in the transform file

The transform file uses a familiar JSON syntax. Within the file, you can define any number of dashboard_elements to append to your existing dashboard. Elements must be placed in either the top-left, top-right, bottom-left, or bottom-right corners of the existing dashboard, specified by the position attribute.

You can also define any number of replacements, which perform a simple find and replace within the JSON output based on the key-value pairs listed. This can be used to automatically replace model names or update filters for existing elements. You must escape double-quotes.

Example JSON transform file:

{
  "dashboard_elements": [
    {
      "position": "top-left"
      "body_text": "Production Version of Dashboard (deployed 2019-05-28)",
      "body_text_as_html": "<p>Production Version of Dashboard (deployed 2019-05-28)</p>",
      "note_display": null,
      "note_state": null,
      "note_text": null,
      "note_text_as_html": null,
      "subtitle_text": "",
      "title": null,
      "title_hidden": false,
      "title_text": "",
      "type": "text",
    },
    {
      "position": "bottom-right"
      "body_text": "Please contact the Business Intelligence Help Desk for any issues with this dashboard",
      "body_text_as_html": "<p>Please contact the Business Intelligence Help Desk for any issues with this dashboard</p>",
      "note_display": null,
      "note_state": null,
      "note_text": null,
      "note_text_as_html": null,
      "subtitle_text": "",
      "title": null,
      "title_hidden": false,
      "title_text": "",
      "type": "text",
    }
  ],
  "replacements": [
    {
      "\"model\": \"staging\",": "\"model\": \"production\",",
      # DG: Replace with working example of checking for a user attribute value in production
      "\"filter_expression\": \"not(is_null(${view.allowed_user}))\": "\"filter_expression\": \"${view.allowed_user} = _user_attributes['username']\",",
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment