Dynatrace Configuration as Code (Monaco)

repository·main·Indexed 41 days ago

https://github.com/dynatrace/dynatrace-configuration-as-code

A CLI tool designed to automate the configuration of Dynatrace environments using an 'as Code' approach for observability and security. Monaco enables the management of standard configurations across environments at scale, supporting the deployment, deletion, and downloading of account management resources such as users, groups, and policies. Version 2.0+ is the officially supported release.

Tokens
32.3K
Snippets
89
Records
128
Agent score
51%

What's inside Monaco

  1. Overview of Dynatrace Configuration as Code (Monaco)

    main

    Dynatrace Configuration as Code, powered by the Monaco CLI, enables Observability as Code and Security as Code. It is designed to automate the configuration of the Dynatrace platform at scale, allowing you to manage standard configurations across all environments or meet specific requirements for individual environments.

    Key resources:

  2. Monaco CLI argument and flag conventions

    main

    The Monaco CLI follows a specific convention for distinguishing between required and optional arguments:

    • Required Arguments: Must be provided without flags. Because they lack flags, the order of arguments is important.
    • Optional Arguments: Must be provided as flags. Because they use flags, the order is not important.

    Example usage: monaco deploy flagValue1 -a dashboards manifest.yaml In this example, manifest.yaml is a required argument (no flag), while -a is an optional flag.

    monaco deploy flagValue1 -a dashboards manifest.yaml
  3. Structure of a Monaco configuration file

    main

    A Monaco configuration file is a JSON object that defines the configurations to be applied to Dynatrace environments. The root object must contain a configs array.

    Each item in the configs array represents a single configuration unit and requires the following fields:

    • id: A unique Monaco identifier used for references and generating IDs in Dynatrace.
    • type: Defines the nature of the configuration (e.g., Classic Config API, Settings 2.0, Automation, Document, or OpenPipeline).
    • config: The actual configuration data, which must include a template (filepath to the JSON template).

    You can also use groupOverrides and environmentOverrides within a config item to modify its values for specific groups of environments or individual environments.

    {
      "configs": [
        {
          "id": "my-config-id",
          "type": "some-type",
          "config": {
            "template": "path/to/template.json",
            "name": "My Config Name"
          }
        }
      ]
    }
  4. Handle non-unique dashboard names during download

    main
    When downloading dashboards, Monaco can handle cases where multiple dashboards share the same name. This is managed using the NonUniqueNameConfigDuplicationParameter. When this parameter is set to true, Monaco will allow the creation of multiple configuration files even if their names are not unique, preventing collisions in the local project structure.
  5. Authentication requirements for configuration types

    main

    Different Dynatrace configuration types require different levels of authentication in your manifest. The deployment will fail if the environment does not meet these requirements:

    Configuration TypeRequired Credentials
    ClassicApiTypeRequires an AccessToken for the environment.
    SettingsTypeRequires an AccessToken OR Platform Credentials. If the AllUserPermission property is used, Platform Credentials are mandatory.
    AutomationType, BucketType, DocumentType, OpenPipelineTypeRequires Platform Credentials.
    Other typesGenerally require Platform Credentials.
  6. Enable dangerous commands via environment variable

    main

    Certain high-impact commands, such as purge, are disabled by default to prevent accidental configuration or environment damage. To enable these commands, you must set the following environment variable:

    MONACO_ENABLE_DANGEROUS_COMMANDS

    Warning: Use these commands with extreme care as they may have a heavy impact on your Dynatrace configurations or environments.

  7. Structure of a Monaco manifest file

    main

    A Monaco manifest file is a JSON or YAML configuration that defines how Dynatrace configurations are organized and where they should be deployed. The manifest acts as the entrypoint for the Monaco CLI to understand your projects, environments, and accounts.

    Key top-level properties include:

    • manifestVersion: The version of the manifest schema.
    • projects: A list of configuration projects to be deployed.
    • environmentGroups: A list of environment groups that projects will be deployed to (required for environment configurations).
    • accounts: A list of accounts that account resources will be deployed to (required for account resources).
    • accounts: A list of accounts that account resources will be deployed to (required for account resources).
  8. Use overrides for groups and environments

    main

    Monaco allows you to define a base configuration and then apply overrides to prevent duplication when deploying the same configuration to multiple environments with slight variations.

    Group Overrides

    groupOverrides allows you to overwrite specific parts of a configuration for all environments belonging to a specific group.

    Environment Overrides

    environmentOverrides allows you to overwrite specific parts of a configuration for a single, specific environment.

    Both override types use the same structure as the base config object, allowing you to change the name, parameters, template, or set skip: true to prevent deployment for that specific context.

    {
      "configs": [
        {
          "id": "multi-env-config",
          "type": "bucket",
          "config": {
            "template": "base-bucket.json",
            "name": "Base Bucket"
          },
          "groupOverrides": [
            {
              "group": "production-group",
              "override": {
                "name": "Prod Bucket"
              }
            }
          ],
          "environmentOverrides": [
            {
              "environment": "dev-env",
              "override": {
                "skip": true
              }
            }
          ]
        }
      ]
    }