cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Copy dashboards between environments

Karolina_Linda
Community Team
Community Team

This tip comes from the Knowledge sharing challenge.

Author: @JamesKitson 

 

Copy dashboards between environments

You may already know that dashboards are represented in configuration as simple json files. These are what you work with when configuring them through the API. An update recently made it possible to work with this json directly in the UI.

This makes it much faster to copy dashboards between environments or to copy or modify some sections in bulk. You can simply copy a dashboard from your QA to Prod environment and change filters etc... instead of trying to replicate the dashboard tile by tile. There's also the standard tricks you can do with text in a text editor such as find and replacing text for example if you wanted to find all occurrences of 'qa' and replace it with 'prod.'

Stuff like this had already been available through the API but with it in the UI you can make big changes in seconds especially if you keep configurations and conventions consistent across any environments you have.

Manage dashboards more efficiently with the json editor

Keep calm and build Community!
8 REPLIES 8

Malaik
DynaMight Advisor
DynaMight Advisor

Hello @Karolina_Linda 

And the new version Dynatrace detect automatically the ENV ID and the Owner when import the Json in the new ENV.

 

Much useful.

Sharing Knowledge

matthias_dillie
Advisor

Monaco can help here too. Download the dashboard definitions (json) with monaco and then deploy them to different environments.

I use this together with a template engine (yasha) to generate environment specific dashboards e.g. different number of tiles - one for each host in the environment - and then deploy them to the different environments. Setting permissions is still missing, so you have to set them in the gui.

Malaik
DynaMight Advisor
DynaMight Advisor

Hi
Can you tell us more about this tool?
Is it integrated with Dynatrace...

Thanks

 

Sharing Knowledge

@Malaik 

I suppose you are referring to the "json editor". It is integrated in the Dynatrace platform, and you can see more info here:

https://www.dynatrace.com/support/help/how-to-use-dynatrace/dashboards-and-charts/dashboards/dashboa...

Antonio Sousa

Hi Antonio
No, not directly.

In the json-editor you can directly edit the json for a dashboard and you can copy this from one environment into another.
For such tasks I use monaco where this is possible. See
https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/blob/main/README.md
See also my post
https://github.com/dynatrace-oss/dynatrace-monitoring-as-code/discussions/522


In monaco you can use variables in the json for the dashboard. As soon as you need some more flexibility, a template engine integrated in monaco would help a lot.

For now, I use the jinja2 template engine yasha. I have a file *Vars.json with variable definitions like the names of hosts in an environment. Then I have a *.json.j2 with a jinja2 template to generate dashboard-json files with e.g. a dashboard tile for every host in the variable file and the position of the tile set correctly. Then I have a skript file yasha.sh with a loop to call a yasha command for all dashboards and templates to generate all dashboard-json files for all environments. And finally I can deploy the dashboards with monaco to all dynatrace environments.
As a starting point, you can interactively create a dashboard and then download it with monaco. You then can use the downloaded dashboard-json to create the jinja2-template and then to compare the template generated new dashboard-json with the downloaded one.

@matthias_dillie 

Yes, the Monaco approach is very good for automating dashboard management, including across several environments. This is related to the API approach that exists for a long time now. The UI approach is a little bit more recent, and it permits to start copying dashboards in the old copy&paste strategy, without the API knowledge 🙂

Antonio Sousa

RajeshG
Participant

Yeah that's correct @AntonioSousa, the UI approach is much more simpler than API and Monaco methods.

While Copy & paste Dynatrace auto detects the Env ID and other details to match up with the pasted environment, which is more hassle free. But what I see while pasting is, some metrics & filters doesn't cope up with the copy&paste mechanism(due to unavailability of metrics or syntax errors) and eventually Dashboard throws errors. We should be knowledgeable to edit/modify them to apply changes.

This goes more cautious with custom metric dashboards too. 

many thanks,

Rajesh

@RajeshG,

Yes, if you have filters, you will have to adapt to new entities. Typically, a find&replace might help, but you do have to get to know where that information is. In any case, you can edit them in Data Explorer and change them; if you have a lot of dashboards, doing some find&replace or even automation, might help.

Antonio Sousa