RousselTMLEARNING

Observability

Configuration as Code with Monaco: tokens, OAuth, projects and CI/CD

Manage Dynatrace configuration as code with Monaco: API tokens and OAuth clients, manifest, projects and configurations, download, deploy, Docker image and GitHub Actions and GitLab CI pipelines.

1. Why Monaco? #

No more untracked clicks.

Principle #

Monaco cycle
The same configuration can be deployed to several environments.

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 #

TypeUsageCreation
API tokenEnvironment API (classic configurations, settings)Access tokens, with only the permissions needed (read/write settings and configurations)
OAuth clientPlatform 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: environment
monaco 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 proprement
Good 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.

Related articles

Accessing the Dynatrace playground and getting started

The Dynatrace playground is a demo environment full of real data: how to access it, what it allows and does n…

Grail buckets in Dynatrace: creation, routing, retention, rights and costs

Complete guide to Grail buckets: purpose, default buckets, creation in Storage management, with the API or Te…

The Dynatrace QuickStart app: getting your first data in minutes

Discover the QuickStart app: add data with Auto Discovery or a dedicated tile, read Findings, explore with da…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!