An alerting profile edited by hand in production, another one forgotten in pre-production, and nobody knows who changed what. This Dynatrace Monaco tutorial shows how Monitoring as Code fixes that: your environments’ configuration lives in YAML and JSON files versioned in Git, reviewed in merge requests and deployed by CI like any other code.
For an SRE team, the stakes are concrete. Reproducible configuration reduces drift between environments, makes every change reversible and removes the toil of repeating manual settings across ten environments. During an incident, a git log answers « what changed? » in seconds.
The goal of this tutorial: install the CLI, download an existing configuration, create a parameterised alerting profile, deploy it as a dry run and then for real, and plug it into a pipeline. Monaco works with Dynatrace SaaS and Dynatrace Managed for classic configuration APIs and Settings 2.0; platform objects (workflows, documents, buckets, recent SLOs) only concern SaaS.
Dynatrace Monaco: the three files to know
| File | Role |
|---|---|
manifest.yaml | Declares the projects (configuration folders) and target environments, with their URLs and the names of the variables holding the secrets |
config.yaml | In each project folder: the list of configurations, their type (classic API, Settings 2.0 schema, workflow…) and their parameters |
| JSON template | The object body, with { { .name } } variables replaced by the parameters at deployment |
This split separates what changes from one environment to another (the parameters) from what does not (the template).
Prerequisites
- The
monaco2.x CLI, downloaded from the releases of theDynatrace/dynatrace-configuration-as-coderepository. - An API token with scopes matching the objects you manage: at least
settings.readandsettings.writefor Settings 2.0,ReadConfigandWriteConfigfor classic APIs. On SaaS, an OAuth client or a platform token for platform objects. - A Git repository and a CI runner able to read secret variables.
A rejected token produces unhelpful 401 or 403 errors in Monaco’s output: the guide Automating administration with the API reminds you how to test a token before using it.
Dynatrace Monaco tutorial step by step
Step 1: install the CLI
# Linux amd64: replace <version> with the latest published release curl -L -o monaco https://github.com/Dynatrace/dynatrace-configuration-as-code/releases/download/v<version>/monaco-linux-amd64 chmod +x monaco sudo mv monaco /usr/local/bin/ monaco version Step 2: write the manifest
manifestVersion: 1.0 projects: - name: alerting environmentGroups: - name: preprod environments: - name: preprod url: type: environment value: DT_PREPROD_URL auth: token: name: DT_PREPROD_TOKEN - name: prod environments: - name: prod url: type: environment value: DT_PROD_URL auth: token: name: DT_PROD_TOKEN Critical line: type: environment. The value is not the URL but the name of the variable that holds it. Same logic for token.name. The file can therefore be committed without any secret. On Managed, the URL looks like https://<domain>/e/<env-id>; on SaaS, https://<env-id>.live.dynatrace.com.
Step 3: start from what exists with download
Rather than writing a template from scratch, download an existing object to get the right format:
export DT_PREPROD_URL="https://<env-id>.live.dynatrace.com" export DT_PREPROD_TOKEN="dt0c01.XXXX" monaco download --manifest manifest.yaml --environment preprod \ --settings-schema builtin:alerting.profile \ --output-folder download Monaco writes a project folder with a config.yaml and one JSON file per object. It only extracts the object’s value, without the API metadata.
Step 4: parameterise the configuration
Copy the downloaded object into alerting/ and replace the team-specific values with variables. The config.yaml:
configs: - id: profil-equipe-paiement type: settings: schema: builtin:alerting.profile scope: environment config: name: Paiement - production template: profil.json parameters: equipe: paiement And the profil.json template, simplified from the download:
{ "name": "{{ .name }}", "severityRules": [ { "severityLevel": "AVAILABILITY", "delayInMinutes": 0, "tagFilterIncludeMode": "INCLUDE_ALL", "tagFilter": ["team:{{ .equipe }}"] } ], "eventFilters": [] } The name field of config.yaml is exposed to the template as { { .name } }; each entry under parameters is exposed under its own name. Keep property names exactly as the download produced them: the Settings 2.0 schema is the reference. The tag rule assumes consistent tagging, see Management zones and automatic tagging.
Step 5: validate, then deploy
monaco deploy manifest.yaml --environment preprod --dry-run monaco deploy manifest.yaml --environment preprod --dry-run checks syntax, references and parameters without calling the API in write mode. The real deployment creates the object or updates it if it already exists: Monaco finds the object through an external ID derived from the project and the configuration id. Running the command again therefore does not create a duplicate.
Step 6: plug in CI
# .gitlab-ci.yml (excerpt) monaco-preprod: stage: deploy script: - monaco deploy manifest.yaml --environment preprod --dry-run - monaco deploy manifest.yaml --environment preprod rules: - if: $CI_COMMIT_BRANCH == "main" monaco-prod: stage: deploy script: - monaco deploy manifest.yaml --environment prod when: manual The DT_PREPROD_* and DT_PROD_* variables come from the CI project’s secrets. Production stays manual: a human approves after seeing pre-production behave correctly.
Step 7: delete cleanly
Removing an entry from config.yaml deletes nothing in Dynatrace. List the object in a delete.yaml file:
delete: - project: alerting type: builtin:alerting.profile id: profil-equipe-paiement monaco delete --manifest manifest.yaml --file delete.yaml --environment preprod How to check that it works
- The
monaco deployoutput ends without errors and lists the deployed configuration. - In the environment, open the alerting profile settings: the « Paiement – production » profile exists with the expected rule.
- Through the API, the object shows up under the schema:
curl -s -H "Authorization: Api-Token $DT_PREPROD_TOKEN" \ "$DT_PREPROD_URL/api/v2/settings/objects?schemaIds=builtin:alerting.profile&fields=objectId,value" | jq '.items[].value.name' - Run
monaco deployagain: the result must be identical, with no new object created.
Good practices
- One source of truth: an object managed by Monaco is no longer edited by hand. Announce it or, better, restrict write rights in the UI.
- Small projects: one folder per domain (alerting, tagging, anomaly detection) and per owning team. Reviews stay readable.
- Dry run every time in merge requests: errors show up before the merge, not during deployment.
- Drift detection: a scheduled download compared with the repository reveals changes made outside Git.
- Consistent alerting: deployed profiles must stay aligned with the notification integrations, otherwise alerts go nowhere.
Frequently asked questions
Does Monaco work with Dynatrace Managed?
Yes for classic configuration APIs and Settings 2.0 objects, with an API token. Types specific to the SaaS platform (workflows, documents, Grail buckets) do not apply to Managed.
Monaco or Terraform?
Monaco is focused on Dynatrace, with a project and environment model that is easy to pick up. Terraform suits teams that already use it for the rest of their infrastructure. What matters is not managing the same object with both tools.
How do I handle secrets in templates?
Declare a parameter of type environment that reads an environment variable at deployment. The secret never goes through the Git repository.
Conclusion
With Dynatrace Monaco, configuration becomes code: a manifest, projects, parameterised templates, a dry run in merge requests and deployment by CI. Start with a simple domain such as alerting profiles, then expand. Every change becomes traceable, reversible and identical from one environment to the next.
span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of its owner. CLI options and schemas change: check them in the official Monaco documentation.
Originally published on span.observer. French version: https://span.observer/fr/dynatrace-monaco-configuration-code/.