cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Variable in AWS tag filter not working

aled
Newcomer

I have a DQL query that is working as expected:

 

 

 

timeseries approximate_number_of_messages_visible=avg(cloud.aws.sqs.approximate_number_of_messages_visible), by: { dt.entity.custom_device } , filter: { in(dt.entity.custom_device, classicEntitySelector("type(custom_device),tag(\"[AWS]environment:prod\")")) }
| fieldsAdd entityName(dt.entity.custom_device)
| fieldsAdd approximate_number_of_messages_visible=arrayLast(approximate_number_of_messages_visible)
| sort approximate_number_of_messages_visible desc
| limit 20

 

 

 

However, I am trying to make the environment filter dynamic in my dashboard using variables, but as soon as I replace the prod string in the classicEntitySelector with a variable, I receive a parse error:

 

 

 

timeseries approximate_number_of_messages_visible=avg(cloud.aws.sqs.approximate_number_of_messages_visible), by: { dt.entity.custom_device } , filter: { in(dt.entity.custom_device, classicEntitySelector("type(custom_device),tag(\"[AWS]environment:$Environment\")")) }
| fieldsAdd entityName(dt.entity.custom_device)
| fieldsAdd approximate_number_of_messages_visible=arrayLast(approximate_number_of_messages_visible)
| sort approximate_number_of_messages_visible desc
| limit 20

 

 

 

 

Here's the error with $Environment value being "prod"

> Parse error.`prod` isn't allowed here. Please check the autocomplete suggestions before the error for alternative options.

By looking at the JSON error, I can see that the variable is "escaped":

 

"queryString": "timeseries approximate_number_of_messages_visible=avg(cloud.aws.sqs.approximate_number_of_messages_visible), by: { dt.entity.custom_device } , filter: { in(dt.entity.custom_device, classicEntitySelector(\"type(custom_device),tag(\\\"[AWS]nig_environment:\"prod\"\\\")\")) }\n| fieldsAdd entityName(dt.entity.custom_device)\n| fieldsAdd approximate_number_of_messages_visible=arrayLast(approximate_number_of_messages_visible)\n| sort approximate_number_of_messages_visible desc\n| limit 20",

 

Is there a way to "unescape" it?

1 REPLY 1

mark_bley
Dynatrace Champion
Dynatrace Champion

Yes, you need to use concat for these values e.g.:

fetch dt.entity.cloud_application
| fields id, namespace.name = namespaceName, Name = entity.name, Type = arrayFirst(cloudApplicationDeploymentTypes)
| filter namespace.name == "openshift-etcd-operator" AND Type != "KUBERNETES_POD"
| filter in(id, classicEntitySelector(concat("type(CLOUD_APPLICATION),toRelationship.isClusterOfCa(type(KUBERNETES_CLUSTER),entityName.equals(",$Cluster,"))")))

 

Something lik this for your use case:

classicEntitySelector(concat("type(custom_device),tag(\"[AWS]environment:", $Environment, ")"))

Featured Posts