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.
Command | Description |
---|---|
deploy manifest.yaml | Deploy configurations to the environments defined in the specified deployment manifest file. |
deploy --project or -p | optional Specify one or more projects to be deployed to your environments. |
deploy --environment or -e | optional Apply your configurations to specific environments within your deployment manifest file. |
deploy --group or -g | optional Apply your configurations to specific environment groups within your deployment manifest file. |
deploy --continue-on-error or -c | optional Proceed with deployment even if an error is encountered. Ensure configurations that are valid are applied to your environments. |
deploy --dry-run or -d | optional 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.
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:
HTTPS_PROXY=localhost:5000 monaco deploy example.yaml
$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.
Command | Description |
---|---|
download manifest manifest.yaml environment | Download the entire configuration from the environment environment specified in manifest.yaml . |
download direct https://env.dynatracelabs.com TOKEN | Download the entire configuration from the environment at https://env.dynatracelabs.com using the environment variable TOKEN . |
download [manifest/direct] [args] --output-folder | optional Where to store the downloaded project. |
download [manifest/direct] [args] --project | optional The name of the project containing all downloaded configurations. |
download [manifest/direct] [args] --api | optional 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-schema | optional 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-apis | optional Do not download any settings, only configuration APIs. |
download [manifest/direct] [args] --only-settings | optional Do not download any config APIs, only configuration Settings 2.0 objects. |
download [manifest/direct] [args] --force | optional Overwrite any existing manifest.yaml rather than creating an additional manifest file. |
Using the manifest
-
Create a manifest file if you don't have one already.
-
Run Configuration as Code using the
download
command:monaco download manifest manifest.yaml environment-name
Use the
--help
argument to view all options: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.
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:
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:
MONACO_CONCURRENT_REQUESTS=15 monaco download direct https://environment.dynatracelabs.com API_TOKEN_ENVIRONMENT_VARIABLE
$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.
Command | Description |
---|---|
delete manifest.yaml delete.yaml | Remove one or more configurations from one or more Dynatrace tenants. |
delete --environment or -e | optional Delete configurations from specific environments within your deployment manifest file. |
delete --group or -g | optional 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:
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:
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:
delete:
- "infrastructure/my custom service"
The following delete command will remove the my custom service
configuration within the infrastructure
directory from the development environment:
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.
Command | Description |
---|---|
convert environment.yaml v1-project | Apply automatic conversion rules to help convert Monitoring as Code v.1 configuration files to Dynatrace Configuration as Code v.2 files. |
convert --manifest or -m | optional Specify the name to be used for the manifest file produced by the convert command (the default is manifest.yaml ). |
convert --output-folder or -o | optional 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
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.
MONACO_REQUEST_LOG=request.log MONACO_RESPONSE_LOG=response.log monaco deploy manifest.yaml
$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.