Ensure order of configurations
This guide shows how to enforce the order of configurations using Dynatrace Configuration as Code via Monaco (Dynatrace Monaco CLI).
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
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
1configs:2 - id: rule23 config:4 name: rule25 template: rule2.json6 skip: false7 type:8 settings:9 schema: builtin:rum.web.app-detection10 schemaVersion: 2.0.111 scope: environment12 - id: rule113 config:14 name: rule115 template: rule1.json16 skip: false17 type:18 settings:19 schema: builtin:rum.web.app-detection20 schemaVersion: 2.0.121 scope: 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
1configs:2 - id: rule23 config:4 name: rule25 template: rule2.json6 skip: false7 parameters:8 order:9 configId: rule110 property: id11 type: reference12 type:13 settings:14 schema: builtin:rum.web.app-detection15 schemaVersion: 2.0.116 scope: environment17 - id: rule118 config:19 name: rule120 template: rule1.json21 skip: false22 type:23 settings:24 schema: builtin:rum.web.app-detection25 schemaVersion: 2.0.126 scope: environment