And I have a variable called Environment with the values DEV, SANDBOX and PROD. I wold like to filter the tile based on the variable but substituting DEV by $Environment doesn’t work.
As you might have noticed from the info message in your environment, the entitySelector will be soon depreciated for usage in DQL. Instead you can use just plain DQL. I guess this example should work for you
What if I also have another tag called Business_Application that works the same way as Environment and I want to filter on the 2 values? I tried this but it doesn’t work (doesn’t show any data but it should)
| filter (toString(tag) == “Business Application” and in(toString(value), array($Business_Application))) and (toString(tag) == “Environment” and in(toString(value), array($Environment)))
I want to revisit the original question because filtering in the timeseries query is faster than filtering after the query. In order to use a variable as part of an entity selector filter in a timeseries query, you need to use classicEntitySelector, concat and toString.
Breaking down the filter, there’s an embedded concat in the classicEntitySelector call with three arguments. The first argument is the beginning of the entity selector in quotes. The second argument is the variable converted to a string. The last argument is a quoted close parentheses to end the entity selector.
Anything you can to do reduce the amount of data returned in the timeseries query will make tiles in dashboards load faster.
We flipped our methodology on this recently.
We created a hidden variable ($app_servers) to create a list of hosts:
Note: that hidden variable needs to be multiselect and default to *
fetch dt.entity.host
|fieldsAdd tags
|filter in(concat("client:",$Client),tags) and in(concat("environment_type:",$Environment),tags)
|fields id
Then our tiles became much simpler by providing a host list.