dynatrace-oss / terraform-provider-dynatrace

Apache License 2.0
70 stars 35 forks source link

dynatrace_entity datasource reads all entities instead of a single entity #432

Closed abky02 closed 7 months ago

abky02 commented 7 months ago

Describe the bug dyntrace_entity datasource does not apply entityName to entitySelector in api call when supplying name and type attribute. This results in every dynatrace entity being read which results in a slow api call. Correct entity specified in name is still retrieved, however the call is slow.

To Reproduce Steps to reproduce the behavior: Prereq: Utilize the below environment variables

DYNATRACE_DEBUG=true
DYNATRACE_HTTP_RESPONSE=true
DYNATRACE_LOG_HTTP=terraform-provider-dynatrace.http.log
  1. Create a dynatrace_entity datasource
  2. Declare attributes name and type
  3. Should see api call take longer than usual if many entities are present in dynatrace environment.
  4. Open the http log file and view the api call being made. What is present should be an api call without entityName included within entitySelector. Should see something like below:
    12:12:36
    GET
    https://<environment>.live.dynatrace.com/api/v2/entities?pageSize=4000&from=now-3y&entitySelector=type%28%22SERVICE%22%29&fields=tags,properties,lastSeenTms

Expected behavior Should have entityName present within entitySelector query param when using dynatrace_entity data source.

Additional context Current work around is to just use entity_selector attribute:

data "dynatrace_entity" "response" {
  entity_selector = <<EOT
    entityName("${var.service_name}"),type("SERVICE")
  EOT
}

Also the current version of dynatrace provider used within this issue is version = ">= 1.54.1 , < 2.0.0"

kishikawa12 commented 7 months ago

Hi @abky02 ,

Release v1.55.0 is now available which includes the fix to this issue.

Thanks!