• Home
  • Manage
  • Configuration as Code
  • Reference
  • Commands

Commands

This command cheat sheet for the Dynatrace Configuration as Code CLI describes the basic commands for managing your configuration files.

Deploy command

The deploy command deploys configurations to environments defined in a given deployment manifest file.

CommandDescription
deploy manifest.yamlDeploy configurations to the environments defined in the specified deployment manifest file.
deploy --project or -poptional Specify one or more projects to be deployed to your environments.
deploy --environment or -eoptional Apply your configurations to specific environments within your deployment manifest file.
deploy --group or -goptional Apply your configurations to specific environment groups within your deployment manifest file.
deploy --continue-on-error or -coptional Proceed with deployment even if an error is encountered. Ensure configurations that are valid are applied to your environments.
deploy --dry-run or -doptional Validate configuration files and skip deployment. It checks whether your Dynatrace configuration files are valid JSON and whether your tool configuration YAML files can be parsed and used.

The most straightforward way to use deploy is to run it without any flags (command options)and pass the file name of your deployment manifest. This way, all configurations in the project section of the deployment manifest file are applied to all environments defined in the environments section of the file.

shell
monaco deploy manifest.yaml

Proxy

In environments where access to Dynatrace API endpoints is only possible or allowed via a proxy server, the Dynatrace Configuration as Code CLI provides an option to specify the address of your proxy server when running a command:

shell
HTTPS_PROXY=localhost:5000 monaco deploy example.yaml
shell
$env:HTTPS_PROXY="localhost:5000" monaco deploy example.yaml

Download command

The download command lets you download configurations from a Dynatrace environment as Configuration as Code files. Use this feature to avoid starting from scratch when using Configuration as Code.

CommandDescription
download manifest manifest.yaml environmentDownload the entire configuration from the environment environment specified in manifest.yaml.
download direct https://env.dynatracelabs.com TOKENDownload the entire configuration from the environment at https://env.dynatracelabs.com using the environment variable TOKEN.
download [manifest/direct] [args] --output-folderoptional Where to store the downloaded project.
download [manifest/direct] [args] --projectoptional The name of the project containing all downloaded configurations.
download [manifest/direct] [args] --apioptional The name of one or more APIs to download (the flag can be repeated or the value can be defined as a comma-separated list).
download [manifest/direct] [args] --settings-schemaoptional The name of one or more Settings 2.0 schemas to download (the flag can be repeated or the value can be defined as a comma-separated list).
download [manifest/direct] [args] --only-apisoptional Do not download any settings, only configuration APIs.
download [manifest/direct] [args] --only-settingsoptional Do not download any config APIs, only configuration Settings 2.0 objects.
download [manifest/direct] [args] --forceoptional Overwrite any existing manifest.yaml rather than creating an additional manifest file.

Using the manifest

  1. Create a manifest file if you don't have one already.

  2. Run Configuration as Code using the download command:

    shell
    monaco download manifest manifest.yaml environment-name

    Use the --help argument to view all options:

    shell
    monaco download manifest --help

Direct download

To download an environment directly without using a manifest, use the monaco download direct command.

You need to supply the name of an environment variable that contains the access token for your Dynatrace environment.

In the example, this variable is API_TOKEN_ENVIRONMENT_VARIABLE.

The same variable name will be used for the manifest that downloading will create for you.

shell
monaco download direct https://environment.dynatracelabs.com API_TOKEN_ENVIRONMENT_VARIABLE

This command will get you started and create a manifest.

After a direct download, you have everything you need to deploy your downloaded configuration.

Use --help to view all options:

shell
monaco download direct --help

Unsupported APIs

Some APIs are supported to be deployed but are not supported to be downloaded. To deploy them, you need to create them manually. These APIs are:

  • aws-credentials
  • azure-credentials
  • kubernetes-credentials
  • credential-vault
  • extension

Concurrent downloads

To ensure that large configuration sets are downloaded as quickly as possible, the download command makes several simultaneous API calls to Dynatrace.

You can set a MONACO_CONCURRENT_REQUESTS environment variable to configure various values for concurrent requests:

shell
MONACO_CONCURRENT_REQUESTS=15 monaco download direct https://environment.dynatracelabs.com API_TOKEN_ENVIRONMENT_VARIABLE
shell
$env:MONACO_CONCURRENT_REQUESTS=15 monaco download direct https://environment.dynatracelabs.com API_TOKEN_ENVIRONMENT_VARIABLE

By default, no more than five concurrent requests to Dynatrace are made. If you need faster downloads and your environment or network setup allows it, you can increase the number of concurrent requests.

Note: If you notice problems with downloading configurations—for example, if the internal network setup is throttling and dropping requests—reduce the number of concurrent requests.

Delete command

The delete command is a convenient way to remove configurations from Dynatrace tenants.

Ideally, you will not want to delete long-lived configurations in your production environments, but sometimes it's necessary.

Configuration as Code is also sometimes used to manage ephemeral configurations in development environments, in which case you can easily use Configuration as Code to clean up those temporary configurations.

CommandDescription
delete manifest.yaml delete.yamlRemove one or more configurations from one or more Dynatrace tenants.
delete --environment or -eoptional Delete configurations from specific environments within your deployment manifest file.
delete --group or -goptional Delete configurations from all environments in specific environment groups within your deployment manifest file.

Usage: delete manifest.yaml delete.yaml [flags]

The delete command takes two arguments as YAML files:

  • A manifest file that contains the list of Dynatrace environments
  • A delete file where defined configurations are to be removed

The content of a delete.yaml is as follows:

yaml
delete: - <api/name> OR <schema/config-id> - …
  • To delete configs, use <api>/<name> (for example, java-service/My Config Name)
  • To delete settings objects, use <schema/config-id> (for example, builtin:anomaly-detection.service/my-service-id)

Example

Suppose we have a deployment manifest file called deployment-file.yaml with the structure below:

yaml
projects: - name: infrastructure path: infrastructure environments: - group: development entries: - name: development url: type: value value: "https://mytenant.live.dynatrace.com" auth: token: name: "TestIt"

And we have a delete.yaml file with the following structure:

yaml
delete: - "infrastructure/my custom service"

The following delete command will remove the my custom service configuration within the infrastructure directory from the development environment:

shell
monaco delete deployment-file.yaml delete.yaml

Note that the delete file must be named delete.yaml.

Convert command

The monaco convert command applies automatic conversion rules to help prepare configuration files that were written for Monitoring as Code version 1 to be used with Dynatrace Configuration as Code version 2. It produces a YAML manifest file that contains a list of environments and projects.

CommandDescription
convert environment.yaml v1-projectApply automatic conversion rules to help convert Monitoring as Code v.1 configuration files to Dynatrace Configuration as Code v.2 files.
convert --manifest or -moptional Specify the name to be used for the manifest file produced by the convert command (the default is manifest.yaml).
convert --output-folder or -ooptional Specify the name of the output folder created by the convert command to store all converted configurations (the default is {v1-project}-v2).

Usage: monaco convert environment-file working-deirectory [flags]

The monaco convert command changes configuration files in a specified directory. The command takes options that are required. These options include a YAML file containing a list of environments, the name of the manifest file that will be produced, the name of the output folder where the converted configurations will be stored, and the name of the folder where the environments file is located.

Example

shell
monaco convert environments.yaml my_example_Working --manifest my_manifest_example --output-folder rootfolder

Debug logging

All Dynatrace Configuration as Code CLI commands accept the optional flag --verbose (or -v for short). This flag enables additional debug information to find errors more easily.

Log files

Use the MONACO_REQUEST_LOG and MONACO_RESPONSE_LOG environment variables to specify a file that logs the HTTP traffic between the Dynatrace Configuration as Code CLI and the Dynatrace API. The log files capture additional debug information,regardless of the --verbose flag setting.

The path for the specified file can be absolute or relative to the current working directory. To specify the log file, set the environment variables.

shell
MONACO_REQUEST_LOG=request.log MONACO_RESPONSE_LOG=response.log monaco deploy manifest.yaml
shell
$env:MONACO_REQUEST_LOG="request.log" $env:MONACO_RESPONSE_LOG="response.log" monaco deploy manifest.yaml

Dynatrace Configuration as Code CLI immediately starts writing all send requests to the specified files.

The content of multipart post requests is not logged. This is a known limitation.