Automation is the key to successful IT operations. Automation is also the key to successful monitoring and how you set up your monitoring environment or software intelligence platform.
Managing your configuration is critically important—you probably wouldn’t let anybody change the configuration of your production monitoring environment without proper staging tests.
Keeping track of all the changes within your configurations is another important aspect of what is commonly known as configuration as code.
Configuration as code helps you automate your deployment
Configuration as code introduces a strategy for managing your Dynatrace monitoring configurations just as you manage your source code. Managing your configurations should follow the same principles and rules that you apply to your critical, production source code. Configurations must be validated, tested, deployed, and versioned in a controlled and reproducible manner.
Without such rules, configuring your environments will result in chaos, and you’ll lose flexibility, speed, and stability.
Dynatrace version 1.161 offers a dedicated Configuration API that helps you keep track of your Dynatrace monitoring environment configurations.
The new Configuration API covers the most important global configurations
The following configurations, along with many others, are covered by the new Configuration API:
- Definition of management zones
- Rule-based tags
- Application detection rules
The Configuration API offers you the opportunity to integrate and manage your monitoring configuration within your own toolchain. The fine-grained structure of each configuration object allows you to build predefined monitoring configuration templates. These templates can be maintained within your own version management system and automatically used by your automation pipeline to pre-configure your Dynatrace monitoring environments.
The current public beta availability of the Configuration API provides several important global configurations. Several more endpoints will follow in upcoming releases.
Example: How to copy all management zones between Dynatrace environments
Let’s introduce the capabilities and the power of the Configuration API with a simple example that can help you save a lot of time during the setup of a new monitoring environment.
First, create an API token in the Dynatrace environment from where you wish to copy your management zone definitions, as shown below. Keep in mind that for simply reading the Configuration API, you should assign the minimal necessary access rights to your API token (see the image below):
After creating the token, you can open the integrated Dynatrace API Explorer that is linked on the token page, or through your account menu as shown below.
From the integrated API Explorer, you can switch between the various APIs that your Dynatrace environment offers. If you select Configuration API, all configuration endpoints are listed. If you authorize your API Explorer with the generated token, you can quickly try out reading requests to any of the endpoints shown in the image below.
In our example, we will list all configured management zones in the given environment and copy these over to a new environment.
Let’s scroll down to the configuration endpoints that are available for listing, modifying, and deleting management zones:
Choose the endpoint for listing all management zones, enter your generated API token in the authorization dialog box, and click the Try it out button to get the list of all defined management zones. The API Explorer automatically generates a Request URL as well as a Curl command you can use within your browser, automation script, or command line:
Now that we have the list of all configured management zones within the environment, we can write a tiny script in Python to fetch and store these configurations on local disk. The script consists of a function for generically fetching a list of configurations and another function for storing the configurations in a dedicated folder structure that resembles the API path. The management zone configurations are stored at
See the example script below:
Execution of the script results in a local directory that lists all the configured management zones. This folder structure reflects the API path and can easily be pushed to the version management tool of your choice (for example, Git).
By fetching and pushing the configuration to a Git repository, you get the delta of recent changes and you can use the Git tagging mechanism to decide which configuration you want to distribute to your Dynatrace environments.
After saving all the management zones into a local directory, you can use the following endpoint to push any of the management zone configurations to your chosen destination environments:
This example showed you how you can save and copy an existing management zone configuration between multiple Dynatrace environments.
For full details, see our Configuration API help topics.