Dynatrace Monaco CLI command reference
This command cheat sheet for Dynatrace Configuration as Code via Monaco (Dynatrace Monaco 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.
Usage
monaco deploy graph <manifest.yaml> [flags]
Example
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.
1monaco deploy manifest.yaml
Positional Arguments required
Argument | Description |
---|---|
| The manifest file defining projects to deploy and the environments to deploy them to. |
Flags optional
Flag | Description |
---|---|
or
| Proceed with deployment even if an error is encountered. This can be used to ensure that all valid configurations are applied to your environments, even if other configurations are invalid or failed to deploy. Using this flag might lead to follow-up errors for configurations that depend on each other. |
or
| Validate configuration file structure without deploying them. With this flag set, A |
or
| Apply your configurations to specific environments within your deployment manifest file. To set multiple environments, either repeat this flag or separate them using a comma ( This flag is mutually exclusive with
|
or
| Apply your configurations to specific environment groups within your deployment manifest file. To set multiple groups, either repeat this flag or separate them using a comma ( This flag is mutually exclusive with
|
or
| Specify one or more projects to be deployed. To set multiple projects, either repeat this flag or separate them using a comma (
|
Proxy
In environments where access to Dynatrace API endpoints is only possible or allowed via a proxy server, the Dynatrace Monaco CLI provides an option to specify the address of your proxy server when running a command:
1HTTPS_PROXY=localhost:5000 monaco deploy example.yaml
Download command
The download
command lets you download configurations from a Dynatrace environment as Dynatrace Monaco CLI files. Use this feature to avoid starting from scratch when using the Dynatrace Monaco CLI.
Usage
There are two ways to define the connection to the Dynatrace environment to download from - either by using a manifest file, or by defining the required values to connect directly using CLI flags.
monaco download [connection flags] [flags]
Use the --help
flag to view all options:
1monaco download --help
Using the manifest
-
Create a manifest file if you don't have one already.
-
Run the Dynatrace Monaco CLI using the
download
command:1monaco download --manifest your-manifest.yaml --environment environment-nameIf you named your manifest file the default
manifest.yaml
, you can omit themanifest
flag:1monaco download --environment environment-name
Connection Flags required
Flag | Description |
---|---|
or
| Path to the manifest file to use for connection information. Default: |
or
| Specify an environment defined in the manifest to download configurations from. |
Direct download
You can use command flags to download an environment directly without using a manifest.
Authentication secrets are always loaded from environment variables, so you need to supply the name of a variable, not the actual secrets, when using the --token
, --oauth-client-credentials
and --oauth-client-secret
flags.
In the example, these environment variables are named API_TOKEN_ENV_VAR
, CLIENT_ID_ENV_VAR
, and CLIENT_SECRET_ENV_VAR
.
The same variable names will be used for the manifest that downloading will create for you.
To download from a Dynatrace Platform environment, you need to supply an API token as well as OAuth credentials:
1download --url https://paltform-env.apps.dynatrace.com --token API_TOKEN_ENV_VAR --oauth-client-id CLIENT_ID_ENV_VAR --oauth-client-secret CLIENT_SECRET_ENV_VAR
To download from earlier generations of Dynatrace, you only need to supply the API token:
1download --url https://env.dynatrace.com --token API_TOKEN_ENV_VAR
This command will get you started and create a manifest.
After a direct download, you have everything you need to deploy
your downloaded configuration.
Connection Flags required
Flag | Description |
---|---|
| URL of the Dynatrace environment from which to download the configuration. To be able to connect to any Dynatrace environment, an API token needs to be provided using In case of connecting to a Dynatrace Platform environment, an additional OAuth Client ID, as well as an OAuth Client Secret, needs to be provided via the flags This flag is mutually exclusive with |
| API token environment variable. Required when using the flag |
| OAuth client ID environment variable. Required when using the flag |
| OAuth client secret environment variable. Required when using the flag |
Flags optional
In addition to the connection flags described above, several options exist that apply to both manifest-based and direct downloads.
Flag | Description |
---|---|
or
| Specify the name of the output folder in which downloaded configurations will be stored. Default: a new folder will be created with the name 'download' and the current timestamp |
or
| The name of the project that will be generated containing all downloaded configurations. Default: |
or
| Download one or more classic configuration APIs, including deprecated ones. (Repeat flag or use comma-separated values) |
or
| Download settings 2.0 objects of one or more settings 2.0 schemas. (Repeat flag or use comma-separated values) |
| Download only classic configuration APIs. Deprecated configuration APIs will not be included. |
| Download only Settings 2.0 configuration objects. Classic configuration APIs will not be included. |
or
| Force overwrite any existing In case of manifest-based download: Never append the source environment name to the project folder name. |
Filtering
The download
command filters out several configurations by default.
Filtering possibilities range from excluding a configuration type completely to just excluding specific configuration objects.
Some types are excluded because the Dynatrace API does not return full information from them. Generally, these types contain secrets that can never be exported after creation:
aws-credentials
azure-credentials
kubernetes-credentials
credential-vault
extension
Specific configuration objects are filtered out if they are read-only configurations that can't be modified.
Deactivate filters
Dynatrace Monaco CLI version 2.2.0+
It's possible to deactivate filtering if you want to download
everything. Keep in mind that such a download
results in a project that can't be deployed
directly and that requires manual post-processing.
Filters can be controlled by the following environment variable flags:
Environment variable | Description |
---|---|
MONACO_FEAT_DOWNLOAD_FILTER | Controls all download filtering. If set to false , no filters are applied. This supersedes all other filtering flags. |
MONACO_FEAT_DOWNLOAD_FILTER_SETTINGS | Controls Settings 2.0 download filtering. If set to false , all settings are downloaded without filtering. This supersedes the MONACO_FEAT_DOWNLOAD_FILTER_SETTINGS_UNMODIFIABLE flag. |
MONACO_FEAT_DOWNLOAD_FILTER_SETTINGS_UNMODIFIABLE | Controls Settings 2.0 download filtering. If set to false , settings that are marked as unmodifiable by the API are downloaded. |
MONACO_FEAT_DOWNLOAD_FILTER_CLASSIC_CONFIGS | Controls classic Config API type download filtering. If set to false , all Config API configurations are downloaded without filtering. |
For example, assume we want to download
all classic Config API types without filtering and also include unmodifiable Settings 2.0 objects.
We can do this by setting two environment variables:
1export MONACO_FEAT_DOWNLOAD_FILTER_CLASSIC_CONFIGS=false2export MONACO_FEAT_DOWNLOAD_FILTER_SETTINGS_UNMODIFIABLE=false3monaco download [flags]
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:
1MONACO_CONCURRENT_REQUESTS=15 monaco download [flags]
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.
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.
Dependency resolution
When downloading, the Dynatrace Monaco CLI resolves references between configurations to ensure that they can be re-uploaded in the correct order. To achieve this, all downloaded JSON templates are parsed and searched for the identifiers of all configurations.
The default version of dependency resolution is CPU intensive and can be slow if run on hardware or containers with limited CPU resources.
Monaco CLI version 2.0.2+ A fast resolver is available to speed this up, which trades off CPU requirements for an increased memory need. To activate it:
-
Make sure the machine has at least 16–32 GB of RAM and several hundred GB of storage available as swap space.
-
Set the
MONACO_FEAT_FAST_DEPENDENCY_RESOLVER
environment variable totrue
.1MONACO_FEAT_FAST_DEPENDENCY_RESOLVER=true monaco download [flags]
Delete command
The delete
command is a convenient way to remove configurations from Dynatrace environments.
Ideally, you will not want to delete long-lived configurations in your production environments, but sometimes it's necessary.
The Dynatrace Monaco CLI is also sometimes used to manage ephemeral configurations in development environments, in which case you can easily use Monaco to clean up those temporary configurations.
Usage
delete [flags]
The delete command requires two YAML files:
A manifest file that contains the list of Dynatrace environments from which to remove configuration
A delete file that defines which configurations are to be removed
If you don't specify file names, the command tries to find a manifest.yaml
and a delete.yaml
file in the current folder.
Example
Suppose we have a deployment manifest file called deployment-file.yaml
with the structure below:
1projects:2 - name: infrastructure3 path: infrastructure45environments:6 - group: development7 entries:8 - name: development9 url:10 type: value11 value: "https://mytenant.live.dynatrace.com"12 auth:13 token:14 name: "TestIt"
And we have a delete.yaml
file with the following structure:
1delete:2 - project: infrastructure3 type: java-service4 name: my-java-service-config
The following delete command will remove the my-java-service-config
configuration within the infrastructure
project from the development environment:
1monaco delete --manifest deployment-file.yaml --file delete.yaml
Flags optional
Flag | Description |
---|---|
or
| Delete configurations from environments defined in a specific manifest file. Default: |
| Delete configurations defined in a specific delete file. Default: |
or
| Specify one or more environments that configurations are deleted from. To set multiple environments, either repeat this flag or separate them using a comma ( This flag is mutually exclusive with
|
or
| Specify one or more environment groups that configurations are deleted from. To set multiple groups, either repeat this flag or separate them using a comma ( This flag is mutually exclusive with
|
Delete files
A delete file consists of entries for each configuration you wish to remove from an environment.
The monaco generate deletefile command allows you to generate a delete file for a given manifest. If you're unsure how to write a delete file, this can be a great starting point.
Entries in a delete file differ slightly depending on the type of configuration:
-
Configurations of type classic config API are identified via their
name
, so the delete entry needs to contain thetype
(API) andname
. -
Objects of other configuration types are identified via generated IDs based on their coordinate, consisting of
type
,project
, andid
, so the delete entry needs to contain thetype
(for example, Settings schema ID),project
, andid
.
Because Settings 2.0 objects are identified by a generated externalID, only objects that were created by or onboarded to Monaco can be deleted.
If you have downloaded existing configurations and you want to delete them using the Dynatrace Monaco CLI, you need to first deploy the downloaded project at least once to make sure Settings 2.0 objects can be found for deletion.
Have a look at this sample delete.yaml
.
1delete:2 # CLASSIC CONFIG OBJECT3 - project: <project-name>4 type: <config-api-name> # for example, "java-service"5 name: <config-name>67 # SETTINGS 2.0 OBJECT8 - project: <project-name>9 type: <settings-schema-id> # for example, "builtin:anomaly-detection.service"10 id: <config-id>1112...
Deprecated shorthand syntax deprecated
Note that there is another syntax for the content of the delete.yaml
file:
1delete:2 - <api/name> OR <schema/config-id>3 - …
However, be aware that this syntax is deprecated and will no longer be supported in future releases. We recommend that you use the more structured format above.
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 Monaco CLI version 2. It produces a YAML manifest file that contains a list of environments and projects.
Usage
monaco convert <environments.yaml> <monaco-v1-project-directory> [flags]
Example
1monaco convert environments.yaml my_example_Working --manifest my_manifest_example --output-folder rootfolder
Positional Arguments required
Argument | Description |
---|---|
| The v1 environments file to convert. |
| The path to a folder containing the v1 project(s) you wish to convert. |
Flags optional
Flag | Description |
---|---|
or
| Specify the name to be used for the manifest file produced by the convert command. Default: |
or
| Specify the name of the output folder created by the convert command to store all converted configurations. Default: a new folder will be created by appending |
or
| Specify one or more projects for which to generate delete file entries. If not defined, all projects in the manifest are used. |
Generate commands
The monaco generate
command offers several sub-commands that allow you to generate auxiliary files from your configuration.
Generate delete file
Dynatrace Monaco CLI version 2.6.0+
The monaco generate deletefile
command creates a delete configuration file for use with the delete command.
Usage
monaco generate deletefile <manifest.yaml> [flags]
Example
1monaco generate deletefile my_manifest.yaml -o deletefiles --file my-projects-delete-file.yaml -p my_project
Positional Arguments required
Argument | Description |
---|---|
| The manifest file for which a delete file is generated. An entry will be generated for each configuration defined in the manifest's projects. |
Flags optional
Flag | Description |
---|---|
| Specify the name of the generated delete file. If a file of this name already exists, a timestamp is appended (default: |
or
| Specify the name of the output folder in which the delete file will be generated. Default: the file is generated in the directory in which you run the command. |
or
| Specify one or more projects for which to generate delete file entries. If not defined, all projects in the manifest are used. |
Generate dependency graph DOT file
Dynatrace Monaco CLI version 2.6.0+
The monaco generate graph
command creates DOT representations of the dependencies between configurations defined in a given manifest's projects.
The DOT format is a standardized text-based format for representing graphs. You can create visual representations with tools such as Graphviz.
Usage
monaco generate graph <manifest.yaml> [flags]
Example
1monaco generate graph manifest.yaml -e dev-environment -o mygraphs_folder
Positional Arguments required
Argument | Description |
---|---|
| The manifest file for which dependency graphs are generated. One DOT file is generated per environment for all configurations defined in the manifest's project. |
Flags optional
Flag | Description |
---|---|
or
| Specify the name of the output folder in which to generate the DOT graph files. Default: the file is generated in the directory in which you run the command. |
or
| Specify one or more environments that should be used for creating dependency graphs. To set multiple environments, either repeat this flag or separate them using a comma ( This flag is mutually exclusive with
|
or
| Specify one or more environment groups to use for creating dependency graphs. To set multiple groups, either repeat this flag or separate them using a comma ( This flag is mutually exclusive with
|
Global Flags optional
The following optional flags can be used with all commands.
Flags | Description |
---|---|
| Create a support archive. |
or
| Enable verbose debug logs. |