# Add these values

**URL:** <https://community.dynatrace.com/t/add-these-values/43518>\
**Category:** DQL\
**Tags:** dql\
**Created:** [January 9, 2024, 2:14pm UTC](https://community.dynatrace.com/t/add-these-values/43518 "2024-01-09T14:14:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 9, 2024, 2:14pm UTC](https://community.dynatrace.com/t/add-these-values/43518/1 "2024-01-09T14:14:22Z")

</div>

Hi  
I want to add these values filter and I want it to affect what is in the view

fetch dt.entity.service  
| fields entity.name, managementZones = managementZones  
| filter matchesValue(managementZones, “prod”)

-------------------------------------------------------------

fetch dt.entity.service  
| expand tags  
| filter contains(tags, “prod”)

The code that is displayed is

const processedResults: MetricResult[] = metricQuery.result[0].data.map(result =\> { return { “Service Name”: result.dimensionMap[“dt.entity.service.name”], “Service ID”: result.dimensionMap[“dt.entity.service”], “Tag”: result.dimensionMap[“dt.entity.service”], “Failure Rate”: +result.values }; });

Is there something I can write instead of dt.entity.service ??

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 9, 2024, 2:46pm UTC](https://community.dynatrace.com/t/add-these-values/43518/2 "2024-01-09T14:46:22Z")

</div>

hi&nbsp;[@yuval1983](https://community.dynatrace.com/user/60894)&nbsp;,

When I run these 2 queries independently, I don’t get any errors on my side.

Are these two different requests? Can you provide us with a screenshot of your query with the visible error please?

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 9, 2024, 6:24pm UTC](https://community.dynatrace.com/t/add-these-values/43518/3 "2024-01-09T18:24:27Z")

</div>

Hi,

I want to filter the table by total of TAGS and ZONE, including a cut according to the filter below, instead of filtering only before the service name.

 ![yuval1983_0-1704824461503.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/7/67f56fe3bf80436d54936f55a9c83cba2c15a4ff.png)

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 9, 2024, 7:34pm UTC](https://community.dynatrace.com/t/add-these-values/43518/4 "2024-01-09T19:34:43Z")

</div>

[@yuval1983](https://community.dynatrace.com/user/60894)&nbsp;  
To use these 2 filters in the same query, you may test :

```markup
fetch dt.entity.service
| fields entity.name, managementZones, tags
| filter matchesValue(managementZones, "prod")
| expand tags
| filter contains(tags, "prod")

```

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 9, 2024, 9:09pm UTC](https://community.dynatrace.com/t/add-these-values/43518/5 "2024-01-09T21:09:11Z")

</div>

> [@gbaudart](https://community.dynatrace.com/user/64996)&nbsp;wrote:
> 
> [@yuval1983](https://community.dynatrace.com/user/60894)&nbsp;  
> To use these 2 filters in the same query, you may test :

```markup
fetch dt.entity.service
| fields entity.name, managementZones, tags
| filter matchesValue(managementZones, "prod")
| expand tags
| filter contains(tags, "prod")

```

 ![yuval1983_0-1704834659168.png](https://global.discourse-cdn.com/dynatrace/original/2X/2/296a2dfc059acb0d91c5100f5360adb2a83c6c89.png)

![yuval1983_1-1704834747815.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/6/c633d3d788c5b2d38dad59a2f4c3899ea8e486c0.png)

Ok, I want to filter the results based on services and tags and display them in a window (table). The filter will look like this: services:test, tags:test2. Also, the Zone:prod .

----------------------------------------------

* * *

What should I replace in this setting?

“Zone”: result.dimensionMap[“dt.entity.service”],  
“Tag”: result.dimensionMap[“dt.entity.service”],

------------------------------

import { metricsClient } from ‘@dynatrace-sdk/client-classic-environment-v2’;

export default async function fetchMetricResults() {  
const serviceSelection = $Service;  
const metricKey = “builtin:service.errors.total.rate”;

const config = {  
metricSelector: buildQuery(serviceSelection, metricKey),  
resolution: “Inf”,  
from: $dt\_timeframe\_from,  
to: $dt\_timeframe\_to,  
acceptType: “application/json; charset=utf-8”  
};

if (config.metricSelector.length \> 3500) {  
return “Please select fewer services”;  
}

const metricQuery = await metricsClient.query(config);

const processedResults: MetricResult[] = metricQuery.result[0].data.map(result =\> {  
return {  
“Service Name”: result.dimensionMap[“dt.entity.service.name”],  
“Service ID”: result.dimensionMap[“dt.entity.service”],  
“Zone”: result.dimensionMap[“dt.entity.service”],  
“Tag”: result.dimensionMap[“dt.entity.service”],  
“Failure Rate”: +result.values  
};  
});

return processedResults;  
}

function buildQuery(inputs: string[], metricKey: string): string {  
const filters = inputs.map(  
input =\> `in(“dt.entity.service”, entitySelector(“type(service), entityName.equals(~”${input}~“)”))`  
);  
const filterString = filters.join(“,”);

return `${metricKey}:filter(or(${filterString})):splitBy(“dt.entity.service”):sort(value(auto, descending)):names`;  
}

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 11, 2024, 7:22am UTC](https://community.dynatrace.com/t/add-these-values/43518/6 "2024-01-11T07:22:23Z")

</div>

HI,

I’m not looking for an error

 ![yuval1983_0-1704957294747.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/e/eeafa254c2bb929b66b52ccaf6f0552bb59fde51.png)

I have created a dashboard and added filters for Service, Zone, and Tag. The filter for Service is working fine and the dashboard is being filtered accordingly when I select a service. However, when I try to filter by Zone or Tag, it doesn’t work and doesn’t display the required information on the dashboard.

I have checked the code and noticed that the following code is used for Service filtering:  
“Service Name”: result.dimensionMap[“dt.entity.service.name”],  
“Service ID”: result.dimensionMap[“dt.entity.service”]

But, I am not sure what code I should use for Zone and Tag filtering. I am not sure which “dt.xxx” I should use for Zone and Tag filtering or what I should configure in the code for filtering by Zone and Tag.

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 11, 2024, 8:00am UTC](https://community.dynatrace.com/t/add-these-values/43518/7 "2024-01-11T08:00:01Z")

</div>

mz and tags are not Dynatrace entities. you will therefore not have an equivalent in dt.xxx. you have to find a workaround

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 11, 2024, 8:24am UTC](https://community.dynatrace.com/t/add-these-values/43518/8 "2024-01-11T08:24:46Z")

</div>

oK

The classic bashboard I can do this filter there according to TAG

Why can’t it be done here?

![yuval1983_0-1704961280352.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/001044783d86b43b1cc2c7f553a9c13b0ea57094.png)

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 11, 2024, 8:33am UTC](https://community.dynatrace.com/t/add-these-values/43518/9 "2024-01-11T08:33:34Z")

</div>

I’m not saying we can’t filter on tags, just that there is no dt.xxx for tags.  
When I want to filter on tags with Grail or the SDK, I generally use an EntitySelector.

However, I am not strong enough in SDK code to easily reformulate your “query”

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 11, 2024, 10:03am UTC](https://community.dynatrace.com/t/add-these-values/43518/10 "2024-01-11T10:03:02Z")

</div>

HI

I was able to create the filter that I needed. Now, I just need to link it to the code inside the table, which I attached above. I’m not sure how to insert this filter into the table’s view.

fetch dt.entity.service  
| expand tags  
| filter contains(tags, “Planning and stability”)  
| fields managementZones, tags

 ![yuval1983_0-1704967248386.png](https://global.discourse-cdn.com/dynatrace/original/2X/a/a0963c1543535161ffaab565f772e83096bfaa64.png)

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 11, 2024, 10:15am UTC](https://community.dynatrace.com/t/add-these-values/43518/11 "2024-01-11T10:15:00Z")

</div>

If you “simply” have to take the filter value.  
I think, You may use the $FILTER variable :

```markup
$Tags_PlanningAndStability

```

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 11, 2024, 10:57am UTC](https://community.dynatrace.com/t/add-these-values/43518/12 "2024-01-11T10:57:12Z")

</div>

OK

Could you assist me in inserting a value into this code? I am having trouble inserting it in a way that it will filter rather than tag. Below is the code that I have mentioned earlier

import { metricsClient } from ‘@dynatrace-sdk/client-classic-environment-v2’;

export default async function fetchMetricResults() {  
const serviceSelection = $Service;  
const metricKey = “builtin:service.errors.total.rate”;

const config = {  
metricSelector: buildQuery(serviceSelection, metricKey),  
resolution: “Inf”,  
from: $dt\_timeframe\_from,  
to: $dt\_timeframe\_to,  
acceptType: “application/json; charset=utf-8”  
};

if (config.metricSelector.length \> 3500) {  
return “Please select fewer services”;  
}

const metricQuery = await metricsClient.query(config);

const processedResults: MetricResult[] = metricQuery.result[0].data.map(result =\> {  
return {  
“Service Name”: result.dimensionMap[“dt.entity.service.name”],  
“Service ID”: result.dimensionMap[“dt.entity.service”],  
“Tag”:&nbsp; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,&nbsp;&nbsp;  
“Failure Rate”: +result.values  
};  
});

return processedResults;  
}

function buildQuery(inputs: string[], metricKey: string): string {  
const filters = inputs.map(  
input =\> `in(“dt.entity.service”, entitySelector(“type(service), entityName.equals(~”${input}~“)”))`  
);  
const filterString = filters.join(“,”);

return `${metricKey}:filter(or(${filterString})):splitBy(“dt.entity.service”):sort(value(auto, descending)):names`;  
}

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 11, 2024, 11:02am UTC](https://community.dynatrace.com/t/add-these-values/43518/13 "2024-01-11T11:02:22Z")

</div>

Try this :

```markup
const processedResults: MetricResult[] = metricQuery.result[0].data.map(result => {
return {
"Service Name": result.dimensionMap["dt.entity.service.name"],
"Service ID": result.dimensionMap["dt.entity.service"],
"Tag": $Tags_PlanningAndStability, 
"Failure Rate": +result.values
};
};

```

On the other hand, to improve the rereading of your code, you should indent it

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 11, 2024, 11:17am UTC](https://community.dynatrace.com/t/add-these-values/43518/14 "2024-01-11T11:17:30Z")

</div>

There is progress now, and I can see the value. However, the filter doesn’t really perform a filter like the service filter’s function. It only shows what I mark inside the filter.

The classic dashboard where I make the change in the filter by filtering, so I see what service is inside that tag.

Thank you for your assistance and patience.

 ![yuval1983_0-1704971590598.png](https://global.discourse-cdn.com/dynatrace/original/2X/b/bbdc8cb3aa673ca849eafb712d0cd389ebe6c7ed.png)

function buildQuery(inputs: string[], metricKey: string): string {  
const filters = inputs.map(  
input =\> `in(“dt.entity.service”, entitySelector(“type(service), entityName.equals(~”${input}~“)”))`  
);  
const filterString = filters.join(“,”);

return `${metricKey}:filter(or(${filterString})):splitBy(“dt.entity.service”):sort(value(auto, descending)):names`;  
}

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 12, 2024, 5:40am UTC](https://community.dynatrace.com/t/add-these-values/43518/15 "2024-01-12T05:40:59Z")

</div>

hi [@Pawel\_Zalewski](https://community.dynatrace.com/user/66060)

Maybe you have a solution ?🙂

---

<div class="post-metadata">

**Author:** ![Pawel\_Zalewski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pawel_zalewski/32/8101_2.png) [@Pawel\_Zalewski](https://community.dynatrace.com/u/Pawel_Zalewski)\
**Post date:** [January 12, 2024, 9:12am UTC](https://community.dynatrace.com/t/add-these-values/43518/16 "2024-01-12T09:12:50Z")

</div>

Hi yuval1983,

I’m afraid I don’t have idea for solution 😞 But I see you made a big progress with&nbsp;[@gbaudart](https://community.dynatrace.com/user/64996), nice work&nbsp;👏

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 12, 2024, 10:14am UTC](https://community.dynatrace.com/t/add-these-values/43518/17 "2024-01-12T10:14:49Z")

</div>

I was able to link a tag to the table, but you pointed out that the name of the service in the table is incorrect. I would like to display all the names under the same tag group. I need help figuring out how to do it.

![yuval1983_1-1705054426836.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/eb48b624d45537c5e99f37e79932d6e1473d4af7.png)

 ![yuval1983_0-1705054415081.png](https://global.discourse-cdn.com/dynatrace/original/2X/7/7a3b0f39e8baa114061adc5310a32cdda63cbf48.png)

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 15, 2024, 5:31am UTC](https://community.dynatrace.com/t/add-these-values/43518/18 "2024-01-15T05:31:20Z")

</div>

HI, [@gbaudart](https://community.dynatrace.com/user/64996)

I need to know how to search for a desired service using tags.

Maybe I need to change something here?

```auto
serviceSelection

```

 ![yuval1983_1-1705296788554.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/7/87a1b02143e529a549982c530e5727732fd4480f.png)

This is the code-

[https://paste.ofcode.org/3863CCfHHf3qzWB2REYYAGA](https://paste.ofcode.org/3863CCfHHf3qzWB2REYYAGA)

Could you please tell me where I can find an index or a way to debug it?

---

<div class="post-metadata">

**Author:** ![gbaudart](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@gbaudart](https://community.dynatrace.com/u/gbaudart)\
**Post date:** [January 15, 2024, 8:56am UTC](https://community.dynatrace.com/t/add-these-values/43518/19 "2024-01-15T08:56:24Z")

</div>

Hi&nbsp;[@yuval1983](https://community.dynatrace.com/user/60894)&nbsp;  
In the EntitySelector command, you can filter with the desired tags like this:

```markup
input => `in("dt.entity.service", entitySelector("type(service), entityName.equals(~"${input}~"), tag("$TAG_VARIABLE")"))`

```

---

<div class="post-metadata">

**Author:** ![yuval1983](https://avatars.discourse-cdn.com/v4/letter/y/0ea827/32.png) [@yuval1983](https://community.dynatrace.com/u/yuval1983)\
**Post date:** [January 21, 2024, 7:02am UTC](https://community.dynatrace.com/t/add-these-values/43518/20 "2024-01-21T07:02:56Z")

</div>

Thank you for your assistance.

I have a new project and need to prioritize, but I will update you once I have more information. Thank you again for your help and prompt responses.
