This command cheat sheet for Dynatrace Configuration as Code via Monaco (Dynatrace Monaco CLI) describes the basic commands for managing your configuration files.
The deploy command deploys configurations to environments defined in a given deployment manifest file.
monaco deploy graph <manifest.yaml> [flags]
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
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:
HTTPS_PROXY=localhost:5000 monaco deploy example.yaml
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.
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:
monaco download --help
Create a manifest file if you don't have one already.
Run the Dynatrace Monaco CLI using the download command:
monaco download --manifest your-manifest.yaml --environment environment-name
If you named your manifest file the default manifest.yaml, you can omit the manifest flag:
monaco download --environment environment-name
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 flag.
In the example, the environment variable is named ACCESS_TOKEN_ENV_VAR.
The same variable name will be used for the manifest that downloading will create for you.
The monaco download --url https://env.dynatrace.com --token ACCESS_TOKEN_ENV_VAR command will get you started and create a manifest.
After a direct download, you have everything you need to deploy your downloaded configuration.
In addition to the connection flags described above, several options exist that apply to both manifest-based and direct downloads.
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-credentialsazure-credentialskubernetes-credentialscredential-vaultextensionSpecific configuration objects are filtered out if they are read-only configurations that can't be modified.
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:
export MONACO_FEAT_DOWNLOAD_FILTER_CLASSIC_CONFIGS=falseexport MONACO_FEAT_DOWNLOAD_FILTER_SETTINGS_UNMODIFIABLE=falsemonaco download [flags]
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 [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.
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 to true.
MONACO_FEAT_FAST_DEPENDENCY_RESOLVER=true monaco download [flags]
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.
monaco delete [--manifest manifest.yaml] [--file delete.yaml] [FLAGS]
The delete command requires two YAML files:
If you don't specify file names, the command tries to find a manifest.yaml and a delete.yaml file in the current folder.
Suppose we have a deployment manifest file called deployment-file.yaml with the structure below:
projects:- name: infrastructurepath: infrastructureenvironments:- group: developmententries:- name: developmenturl:type: valuevalue: "https://mytenant.live.dynatrace.com"auth:token:name: "TestIt"
And we have a delete.yaml file with the following structure:
delete:- type: java-servicename: my-java-service-config
The following delete command will remove the my-java-service-config configuration within the infrastructure project from the development environment:
monaco delete --manifest deployment-file.yaml --file delete.yaml
delete.yaml A delete file, by default named delete.yaml, is a YAML document that lists the configurations that to be deleted by the delete command.
Each entry can reference a configuration directly via its Dynatrace object ID, or indirectly via coordinates.
Only objects created by or onboarded to Monaco can be deleted by indirectly referencing them via coordinates.
If you have downloaded existing configurations and you want to delete them using this method, you need to first deploy the downloaded project at least once to make sure these objects can be found for deletion.
A delete file may not contain entries for dashboard-share-settings or openpipeline configurations. These configurations can't be deleted.
To reference directly, type and objectId must be defined, where type specifies the type of the config, and objectId is the ID of the configuration from Dynatrace.
- type: management-zoneobjectId: origin-object-ID
Depending on the type of configuration, the indirect reference differs slightly.
To create an API entry define the following:
name: the name of the configurationtype: one of supported API types- name: my-mztype: management-zone
To create a Settings entry, define the following:
project: the project name of the configurationid: the ID of the configuration entry inside the config.yaml filetype: one of the Settings 2.0 schema IDs- project: my-projectid: my-auto-tagtype: builtin:auto.tagging
Dynatrace Monaco CLI version 2.6.0+
To create an Automation entry, define the following:
project: the project name of the configurationtype: one of the following values: workflow, scheduling-rule or business-calendarid: the ID of the config entry inside the config.yamlfile- project: my-projecttype: workflowid: my-workflow
Dynatrace Monaco CLI version 2.9.0+
To create a Bucket entry, define the following:
project: the project name of the configurationtype: is set to bucketid: the ID of the config entry inside the config.yamlfile- project: my-projecttype: bucketid: my-bucket
Dynatrace Monaco CLI version 2.15.0+
To create a Document entry, define the following:
project: the project name of the configurationtype: is set to documentid: the ID of the config entry inside the config.yamlfile- project: my-projecttype: documentid: monaco-config-id
Dynatrace Monaco CLI version 2.19.0+
To create a Segment entry, define the following:
project: the project name of the configurationtype: is set to segmentid: the ID of the config entry inside the config.yamlfile- project: my-projecttype: segmentid: my-segment
Type Service-Level Objective (SLO)
Dynatrace Monaco CLI version 2.22.0+
To create a Service-Level Objective (SLO) entry, define the following:
project: the project name of the configurationtype: is set to slo-v2id: the ID of the config entry inside the config.yamlfile- project: my-projecttype: slo-v2id: my-slo
Monaco currently still supports an alternate syntax for delete file entries:
delete:- <api/name> OR <schema/config-id>- …
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.
The monaco generate command offers several sub-commands that allow you to generate auxiliary files from your configuration.
Dynatrace Monaco CLI version 2.6.0+
The monaco generate deletefile command creates a delete configuration file for use with the delete command.
monaco generate deletefile <manifest.yaml> [flags]
monaco generate deletefile my_manifest.yaml -o deletefiles --file my-projects-delete-file.yaml -p my_project
The generate deletefile command can't process configurations that contain references in their name field and will fail when encountering such configurations.
Example of a problematic configuration:
configs:- id: appRuleconfig:name:configId: applicationconfigType: application-webproperty: nametype: referencetemplate: rule.jsonskip: falsetype:api: app-detection-rule
Workaround: Create the delete file manually or update the generated file to set the configuration name without references. See the delete file format for the correct syntax.
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.
monaco generate graph <manifest.yaml> [flags]
monaco generate graph manifest.yaml -e dev-environment -o mygraphs_folder
Dynatrace Monaco CLI version 2.10.0+
The monaco generate schemas command creates JSON schema files for Monaco's YAML files such as the manifest, configuration, and delete files.
These schema files can be integrated with most common IDEs and advanced editors directly or by using free plugins.
monaco generate schemas [flags]
monaco generate schemas -o monaco_schema_folder
Below we describe one recommended usage example using Visual Studio Code.
If you're using a different editor or IDE, follow the respective documentation for registering JSON schemas in your tool of choice.
Prerequisites:
Once the YAML extension is installed, you can associate specific schemas with Monaco files.
For general information on configuring the YAML extension, see the extension documentation.
We recommend the following configuration entry in your Visual Studio Code settings.json:
"yaml.schemas": {"file:///<path-to-your-schema-folder>/monaco-config.schema.json": "**/*config*.yaml","file:///<path-to-your-schema-folder>/monaco-manifest.schema.json": "**/*manifest*.yaml","file:///<path-to-your-schema-folder>/monaco-delete-file.schema.json": "**/*delete*.yaml"}
In the example configuration above:
<path-to-your-schema-folder> with the path to the generated folder. We recommend using absolute paths.Because the format of manifest or configuration files may change between versions, regenerate the schema definitions with the current version of Monaco.
The following optional flags can be used with all commands.