dynatrace-oss/terraform-provider-dynatrace

Application Detection Reorder Rules

Closed this issue · 4 comments

Currently dynatrace_application_detection_rule_v2 resource does not manage rule ordering, which makes it difficult to create/manage detection rules where prefixes/suffixes are used. It appears that there is now an API that manages relative ordering, which can fill that gap: https://docs.dynatrace.com/docs/discover-dynatrace/references/dynatrace-api/configuration-api/rum/application-detection-configuration/reorder-rules. As a note, while dynatrace_application_detection_rule includes ordering, we are trying to use a distributed management system, meaning that absolute ordering is difficult to maintain.

This request is to:

  • create a data source to retrieve application detection rules (and their ID's)
  • create a resource that uses the API linked as its backend

Hello @sk-securian

It looks like we've been a bit lazy with updating our documentation for that resource. I've made sure that the docs in the registry will be updated with the next release.

You can manage the order of Application Detection Rules managed by the dynatrace_application_detection_rule_v2 resource already. The insert_after attribute takes care of that purpose, like in this example.

resource "dynatrace_application_detection_rule_v2" "foo" {
  description    = "foo"
  application_id = "APPLICATION-################"
  insert_after   = dynatrace_application_detection_rule_v2.bar.id
  matcher        = "DOMAIN_MATCHES"
  pattern        = "foo"
}

resource "dynatrace_application_detection_rule_v2" "bar" {
  application_id = "APPLICATION-################"
  matcher        = "DOMAIN_MATCHES"
  pattern = "bar"
}

Is this something you can use?

The API Endpoint for reordering rules you have found would only work in combination with the resource dynatrace_application_detection_rule.

Both, the resource dynatrace_application_detection_rule and the endpoint for reordering the rules are based on the Config V1 REST API.
The resource dynatrace_application_detection_rule_v2 is managed by Dynatrace's Settings 2.0 API.
And while both dynatrace_application_detection_rule and dynatrace_application_detection_rule_v2 are managing the same settings, they are unfortunately not interchangeable. Depending on the REST API different kinds of IDs are required to be used.

About your request for a data source for Application Detection Rules. That would be something that would definitely ease up creating Terraform Modules for you? Or is it a "nice to have" feature?
If it's the first, we will consider implementing such a data source. But I need to ask for patience until next year.

Ah thanks for pointing that out! I think the insert after should work for our use case. Think it is a nice to have the data source (definitely no rush)-as it is, we currently separate the creation of each stack of application/detection rules/data privacy/error rules/custom tags for organizational purposes, so would be helpful to be able to reference between files without having to output/input, but as it is we can probably just use choreo to make sure that most of our stuff is added in the right order.

Thanks for the response. I am tracking the request for a data source in a separate ticket.
For your reference: #619