1. Why Monaco? #
No more untracked clicks.
Principle #
Monaco (Monitoring as Code) is Dynatrace's command-line tool for describing configuration (management zones, alerts, automatic tags, dashboards, SLOs, workflows...) in YAML and JSON files, then deploying it reproducibly to one or more environments.
Dynatrace also offers a Terraform provider; Monaco remains the native tool, suited to teams that want to replicate a configuration across environments.
2. Authentication #
Tokens and OAuth clients.
Access #
| Type | Usage | Creation |
|---|---|---|
| API token | Environment API (classic configurations, settings) | Access tokens, with only the permissions needed (read/write settings and configurations) |
| OAuth client | Platform API (documents, workflows, buckets, recent SLOs) | Account Management > Identity & access > OAuth clients |
Common mistake: Never commit a token: Monaco reads secrets from environment variables, provided by the CI vault.
3. Manifest, projects and commands #
The structure of a Monaco repository.
manifest.yaml #
manifestVersion: 1.0
projects:
- name: socle
environmentGroups:
- name: production
environments:
- name: prod-eu
url: { type: environment, value: DT_URL }
auth:
token: { name: DT_TOKEN }
oAuth:
clientId: { name: OAUTH_CLIENT_ID }
clientSecret: { name: OAUTH_CLIENT_SECRET }# socle/zones/config.yaml
configs:
- id: mz-boutique
config:
name: Boutique
template: mz.json
parameters:
environnement: prod
type:
settings:
schema: builtin:management-zones
scope: environmentmonaco download --manifest manifest.yaml --environment prod-eu # récupérer l'existant
monaco deploy manifest.yaml --dry-run # valider sans rien changer
monaco deploy manifest.yaml --environment prod-eu # appliquer
monaco delete --manifest manifest.yaml --file delete.yaml # supprimer proprementGood practice: Start with monaco download on an existing environment: you immediately get real examples of each configuration type.4. CI/CD #
Deploying automatically.
Docker image and pipelines #
FROM alpine:3.20
ARG MONACO_VERSION=v2.15.0 # choisir la dernière version publiée
RUN apk add --no-cache curl ca-certificates \
&& curl -fsSL -o /usr/local/bin/monaco \
https://github.com/Dynatrace/dynatrace-configuration-as-code/releases/download/${MONACO_VERSION}/monaco-linux-amd64 \
&& chmod +x /usr/local/bin/monaco
ENTRYPOINT ["monaco"]# .gitlab-ci.yml
stages: [verifier, deployer]
verifier:
stage: verifier
image: registry.example.org/outils/monaco:latest
script: [monaco deploy manifest.yaml --dry-run]
deployer:
stage: deployer
image: registry.example.org/outils/monaco:latest
script: [monaco deploy manifest.yaml --environment prod-eu]
rules: [{ if: '$CI_COMMIT_BRANCH == "main"' }]# .github/workflows/monaco.yml (extrait)
- name: Déployer la configuration Dynatrace
run: monaco deploy manifest.yaml --environment prod-eu
env:
DT_URL: ${{ secrets.DT_URL }}
DT_TOKEN: ${{ secrets.DT_TOKEN }}
OAUTH_CLIENT_ID: ${{ secrets.OAUTH_CLIENT_ID }}
OAUTH_CLIENT_SECRET: ${{ secrets.OAUTH_CLIENT_SECRET }}Good to know: The « Dynatrace Simply Smarter » project and the official examples in the dynatrace-configuration-as-code-samples repository provide configurations ready to adapt.