Ensure order of configurations
This guide shows how to enforce the order of configurations using Dynatrace Configuration as Code via Monaco (Dynatrace Monaco CLI).
Goal
While the web UI allows you to define the order of certain configurations, it's not possible to define an order with the Dynatrace Monaco CLI or the Dynatrace API.
- Using the API directly, you can control if rules are appended or pre-pended, but not in the exact order.
- Using the Dynatrace Monaco CLI, this control is not possible.
However, you can use the way the Dynatrace Monaco CLI handles dependencies between configurations to enforce rule order.
Define rule order using dependencies
Dynatrace Monaco CLI version 2.14.1+
For Settings objects that support a specific order, Configuration As Code can ensure the correct ordering by using the insertAfter
parameter in the config.yaml
file. Please take a look at the
documentation for settings type configurations for a concrete description as well as an example.
This guide still applies for ordering other configuration types like Configuration API types.
By creating fake dependencies between rules, the Dynatrace Monaco CLI ensures that a rule is created before another rule that depends on it. This workaround is successful only if all the rules are created from the Dynatrace Monaco CLI and don't already exist.
If rules already exist, you can manually re-order them, with updates from future configuration deployments not impacting the order.
Because newly added rules are prepended to existing rules, you will likely need to define dependencies in the opposite order than you expect. The following sample shows how to ensure order using dependencies.
Consider the following example showing a config.yaml
file containing two app detection rules named rule1
and rule2
.
configs:- id: rule2config:name: rule2template: rule2.jsonskip: falsetype:settings:schema: builtin:rum.web.app-detectionschemaVersion: 2.0.1scope: environment- id: rule1config:name: rule1template: rule1.jsonskip: falsetype:settings:schema: builtin:rum.web.app-detectionschemaVersion: 2.0.1scope: environment
During the deployment process, rule2
probably will be deployed before rule1
. However, to guarantee that rule1
is always deployed before rule2
, you can introduce a pseudo reference parameter within rule2
, indicating its dependency on rule1
. This ensures that rule2
is deployed after rule1
.
configs:- id: rule2config:name: rule2template: rule2.jsonskip: falseparameters:order:configId: rule1property: idtype: referencetype:settings:schema: builtin:rum.web.app-detectionschemaVersion: 2.0.1scope: environment- id: rule1config:name: rule1template: rule1.jsonskip: falsetype:settings:schema: builtin:rum.web.app-detectionschemaVersion: 2.0.1scope: environment