dynatrace-oss / terraform-provider-dynatrace

Apache License 2.0
71 stars 33 forks source link

[Question] using entitySelector on dynatrace_entities #284

Closed devppratik closed 1 year ago

devppratik commented 1 year ago

When using the dynatrace API, I can use something like /api/v2/entities?entitySelector=type(%22HOST_GROUP%22),toRelationships.isInstanceOf(type(%22HOST%22),tag(%22%5BEnvironment%5Dcluster-type:cluster-type-1%22)) with curl to get the desired result

I wanted to achieve the same with tf but cannot there is no way to use entitySelector on dynatrace_entities in terraform.

Is there any other way this can be achieved?

Dynatrace-Reinhard-Pilz commented 1 year ago

Hello @devppratik, An attribute entity_selector for the data source dynatrace_entities is very high on our list. We recently introduced it to dynatrace_entity. Within the next one or two weeks you can expect that to be implemented.

devppratik commented 1 year ago

Thanks @Dynatrace-Reinhard-Pilz ! Looking forward to it

PraveenBegur commented 1 year ago

Hi @Dynatrace-Reinhard-Pilz ,

Thanks for the update on Entity Selector.

In the data source 'dynatrace_entities', I would like to get customized set of fields, attributes/properties in the response json.

For ex: If I query 'dynatrace_entities' for entity type 'kubernetes_cluster', the attribute named like 'k8s cluster Id' should be fetched.

Is this supported in the coming releases?

Dynatrace-Reinhard-Pilz commented 1 year ago

Hello @PraveenBegur,

Since v1.33.0 the data source dynatrace_entity and dynatrace_entities are by default offering the attribute properties. If the entity type is KUBERNETES_CLUSTER the k8s_cluster_id will be contained within that map.

Looking at how you've phrased your question, what you're hoping for is a data source like

data "dynatrace_entity_property" "k8s_cluster_id" {
  entity_selector = "...."
  key = 'k8s_cluster_id"
  # value = <produced_by_data_source>
}

Am I wrong here, or are the current capabilities of dynatrace_entity and dynatrace_entities sufficient enough for your use case?

Dynatrace-Reinhard-Pilz commented 1 year ago

Hello everyone, With the next release the data source dynatrace_entities will accept the attribute entity_selector as an alternative to the attribute type. Both data source, dynatrace_entity and dynatrace_entities will produce an extensive list of properties as a result.