08 Jan 2026 05:15 PM
Building reusable dashboards is not easy. Sometimes you need to include the same set of widgets across your dashboards and make changes in a single place in your config as code.
Dynatrace Monaco has supported the file parameters already for a while, which allows you to include data from a file as a parameter. So we want to define our snippets and use them in our dashboards.
In my example for Dashboards Classic, I have two snippets:
We need to specify the boundaries (basically top left position of the snippet) and path to the include file. The escape: false parameters ensures the file won't be escaped and will be processed correctly. We also need to reference the parameters being used in the snippet.
Of course, both of the snippet references need to be included in the main dashboard.json.
configs:
- id: dashboard-snippet1
config:
name: "Dashboard with Snippets1"
parameters:
# General parameters
serviceTag: "service1"
processTag: "process1"
# Snippet for JVM Metrics
snippet_JVM_left: 0 # left snippet boundary
snippet_JVM_top: 0 # top snippet boundary
snippet_JVM:
type: file
path: snippets/JVM.json
escape: false
references:
- snippet_JVM_left
- snippet_JVM_top
- processTag
# Snippet for Service Metrics
snippet_ServiceMetrics_left: 0 # left snippet boundary
snippet_ServiceMetrics_top: 304 # top snippet boundary - this has to be a constant we can't do relative calculation
snippet_ServiceMetrics:
type: file
path: snippets/ServiceMetrics.json
escape: false
references:
- snippet_ServiceMetrics_left
- snippet_ServiceMetrics_top
- serviceTag
template: dashboard.json
skip: false
type:
api: dashboard
Snippets themselves have to lay out it's tiles based on parameters. This allows having relative positions of the tiles on a classic dashboard.
A complete sample is available in my GitHub repository https://github.com/juliusloman/dynatrace-configuration-as-code-advanced-samples
Featured Posts