# Issues with API filter

**URL:** <https://community.dynatrace.com/t/issues-with-api-filter/50497>\
**Category:** Dynatrace API\
**Tags:** dynatrace-managed, kubernetes, dynatrace-api\
**Created:** [February 27, 2025, 11:21pm UTC](https://community.dynatrace.com/t/issues-with-api-filter/50497 "2025-02-27T23:21:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrazyHarry](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@CrazyHarry](https://community.dynatrace.com/u/CrazyHarry)\
**Post date:** [February 27, 2025, 11:21pm UTC](https://community.dynatrace.com/t/issues-with-api-filter/50497/1 "2025-02-27T23:21:35Z")

</div>

I am really stuck - Trying to create a filter for :

```auto
dt.entity.cloud_application

This is the query that I'm trying to apply the filter for cloud application to. This query returns all apps within a management zone. Trying to filter by a single app or a list of apps.

```

```auto
url = 'https://xxxxxx/e/xxxxx/api/v2/metrics/query?metricSelector=' \
    '(builtin:kubernetes.pods:last:splitBy("dt.entity.cloud_application"):sum:sort(value(avg,descending))):' \
    'names:fold(auto)&from=1739297079132&to=1739304279132&mzName=mzId(MBF)'

```

```auto
Can someone please provide me with the proper syntax for this API request?

```

---

<div class="post-metadata">

**Author:** ![PacoPorro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pacoporro/32/36087_2.png) [@PacoPorro](https://community.dynatrace.com/u/PacoPorro)\
**Post date:** [February 28, 2025, 9:11am UTC](https://community.dynatrace.com/t/issues-with-api-filter/50497/2 "2025-02-28T09:11:32Z")

</div>

try&nbsp; without quotes

```javascript
https://xxxxxx/e/xxxxx/api/v2/metrics/query?metricSelector=(builtin:kubernetes.pods:last:splitBy("dt.entity.cloud_application"):sum:sort(value(avg,descending))):names:fold(auto)&from=1739297079132&to=1739304279132&mzName=mzId(MBF)

```

---

<div class="post-metadata">

**Author:** ![CrazyHarry](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@CrazyHarry](https://community.dynatrace.com/u/CrazyHarry)\
**Post date:** [February 28, 2025, 12:27pm UTC](https://community.dynatrace.com/t/issues-with-api-filter/50497/3 "2025-02-28T12:27:36Z")

</div>

Sorry about that, my question wasn’t clear.&nbsp; I fixed that.&nbsp; &nbsp;What I’m looking for is a query where I can specify one or more apps.

---

<div class="post-metadata">

**Author:** ![izabelarokita](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/izabelarokita/32/41812_2.png) [@izabelarokita](https://community.dynatrace.com/u/izabelarokita)\
**Post date:** [May 21, 2025, 9:06am UTC](https://community.dynatrace.com/t/issues-with-api-filter/50497/4 "2025-05-21T09:06:28Z")

</div>

Hey&nbsp;[@CrazyHarry](https://community.dynatrace.com/user/80990)&nbsp;,&nbsp;did you manage to find the solution to your problem? If so, it would be amazing if you’ve shared it with the rest of the Community! If not, let me know, and I’ll look for some further assistance&nbsp;:blush:

---

<div class="post-metadata">

**Author:** ![CrazyHarry](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@CrazyHarry](https://community.dynatrace.com/u/CrazyHarry)\
**Post date:** [May 21, 2025, 4:15pm UTC](https://community.dynatrace.com/t/issues-with-api-filter/50497/5 "2025-05-21T16:15:49Z")

</div>

Here is the solution:

url = “[https://xxx.xxx/e/xxxxxx/api/v2/metrics/query?metricSelector=](https://xxx.xxx/e/xxxxxx/api/v2/metrics/query?metricSelector=)” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “(builtin:kubernetes.workload.cpu\_usage:filter(and(or(in(\“dt.entity.cloud\_application\_namespace\”,” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “entitySelector(\“type(cloud\_application\_namespace),entityName.equals(~\”” + Namespace\_user + “~\”)\“))))): " \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “splitBy(\“dt.entity.cloud\_application\”):percentile(90.0):sort(value(percentile(90.0),descending))):” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “names:fold(percentile(90)),” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “(builtin:kubernetes.workload.pods\_desired:filter(and(or(in(\“dt.entity.cloud\_application\_namespace\”,” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “entitySelector(\“type(cloud\_application\_namespace),entityName.equals(~\”” + Namespace\_user + “~\”)\”))))): " \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “splitBy(\“dt.entity.cloud\_application\”):max:sort(value(max,descending))):names:fold(percentile(90)), " \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “(builtin:kubernetes.workload.memory\_working\_set:filter(and(or(in(\“dt.entity.cloud\_application\_namespace\”, " \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “entitySelector(\“type(cloud\_application\_namespace),entityName.equals(~\”” + Namespace\_user + “~\”)\”))))):” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “splitBy(\“dt.entity.cloud\_application\”):percentile(90.0):sort(value(percentile(90.0),descending))):” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “names:fold(percentile(90))&” \&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; “from=” + str(start\_epoch\_time) &nbsp;+ “&to=” + str(end\_epoch\_time) &nbsp;+ “&resolution=1m&mzSelector=mzName(” + MNE + “)”
