# Dynatrace Managed. Query multiple environments for alerts

**URL:** <https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725>\
**Category:** Alerting\
**Tags:** dynatrace-managed, problems-classic\
**Created:** [July 1, 2020, 9:13am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725 "2020-07-01T09:13:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![irakli\_natsvlis](https://avatars.discourse-cdn.com/v4/letter/i/edb3f5/32.png) [@irakli\_natsvlis](https://community.dynatrace.com/u/irakli_natsvlis)\
**Post date:** [July 1, 2020, 9:13am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/1 "2020-07-01T09:13:39Z")

</div>

Hello,

Here is the situation - we have Dynatrace Managed with a number of (in dozens and hundreds) of different monitored environments.

I would like to make an API call to find out if all or subset of these environments (selected from a list) logged the specific type of alert during a specific timeframe.

For example - list all environments experienced ‘slow disk’ alerts on the specific day with a timestamp of start/stop of the alert.

How can I do the above **using a single request**?

I know how to query a specific environment for all/specific types of alerts using GET -

```auto
/api/v1/events

```

But as I said - I have hundreds of such environments and it would require to create access token for each environment and query each of them separately. This is not a practical solution.

Any alternatives?

Thanks

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [July 1, 2020, 9:41am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/2 "2020-07-01T09:41:57Z")

</div>

There is no such option to query multiple environments. You will have to get Api Token for each one and query them individually.

Luckily, you should be able to automate this using the Cluster API v2. I did not try this yet on my own, but you should be able to create a token management token for each environment and then create the required API token for each environment.

---

<div class="post-metadata">

**Author:** ![Radoslaw\_Szulgo](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radoslaw_szulgo/32/1977_2.png) [@Radoslaw\_Szulgo](https://community.dynatrace.com/u/Radoslaw_Szulgo)\
**Post date:** [July 1, 2020, 9:46am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/3 "2020-07-01T09:46:57Z")

</div>

Hi Irakli - take a look at my example here that I show how I update Frequent Issues Detection settings for many environments using Ansible:

> **[providing-dynatrace-managed-as-a-service/update-existing-environment at master ·...](https://github.com/rszulgo/providing-dynatrace-managed-as-a-service/tree/master/update-existing-environment)**
>
> master/update-existing-environment

You cannot do that with a single call, but that’s not bad when you automate that - you can call single… script.

---

<div class="post-metadata">

**Author:** ![irakli\_natsvlis](https://avatars.discourse-cdn.com/v4/letter/i/edb3f5/32.png) [@irakli\_natsvlis](https://community.dynatrace.com/u/irakli_natsvlis)\
**Post date:** [July 1, 2020, 10:09am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/4 "2020-07-01T10:09:04Z")

</div>

I am kinda surprised that such a feature is not implemented…

Let me try your approach but in one of our clusters we have ‘2047 Environments’ (not a joke) and I can imagine how much time will it take to go thru all of them.

The problem with the script that in it could be 15 from 2000 environments which experience such alert type but unless I query **all of them** , I won’t be able to see which one was…

---

<div class="post-metadata">

**Author:** ![irakli\_natsvlis](https://avatars.discourse-cdn.com/v4/letter/i/edb3f5/32.png) [@irakli\_natsvlis](https://community.dynatrace.com/u/irakli_natsvlis)\
**Post date:** [July 1, 2020, 10:12am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/5 "2020-07-01T10:12:48Z")

</div>

I just looked at cluster API v2. I See

#### [Environments](https://weu.apm.sap.cx/rest-api-doc/index-managed.jsp?urls.primaryName=Cluster%20API%20v2#/Environments)

Manage environments

#### [Migration to multi-datacenter deployment](https://weu.apm.sap.cx/rest-api-doc/index-managed.jsp?urls.primaryName=Cluster%20API%20v2#/Migration%20to%20multi-datacenter%20deployment)

Migration to multi-datacenter deployment

#### [Remote access](https://weu.apm.sap.cx/rest-api-doc/index-managed.jsp?urls.primaryName=Cluster%20API%20v2#/Remote%20access)

Manage remote access requests

#### [Synthetic - Locations and nodes](https://weu.apm.sap.cx/rest-api-doc/index-managed.jsp?urls.primaryName=Cluster%20API%20v2#/Synthetic%20-%20Locations%20and%20nodes)

Manage synthetic locations and nodes

#### [Tokens](https://weu.apm.sap.cx/rest-api-doc/index-managed.jsp?urls.primaryName=Cluster%20API%20v2#/Tokens)

Manage Dynatrace API authentication tokens

#### [User management](https://weu.apm.sap.cx/rest-api-doc/index-managed.jsp?urls.primaryName=Cluster%20API%20v2#/User%20management)

Manage user sessions

How above is going to help me? One way or another, I need to create a token for each environment and then using that token query alerts. Nothing has changed, in terms of reducing time to get my answers, right?

Thanks

---

<div class="post-metadata">

**Author:** ![irakli\_natsvlis](https://avatars.discourse-cdn.com/v4/letter/i/edb3f5/32.png) [@irakli\_natsvlis](https://community.dynatrace.com/u/irakli_natsvlis)\
**Post date:** [July 1, 2020, 10:13am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/6 "2020-07-01T10:13:40Z")

</div>

Sorry, I added my comment in the main thread.

---

<div class="post-metadata">

**Author:** ![Radoslaw\_Szulgo](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radoslaw_szulgo/32/1977_2.png) [@Radoslaw\_Szulgo](https://community.dynatrace.com/u/Radoslaw_Szulgo)\
**Post date:** [July 1, 2020, 10:14am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/7 "2020-07-01T10:14:31Z")

</div>

It’s intentionally not implemented. The way we store separately data per environment, server would need to run the workload of iterating of hundreds or thousands of envs. You rather don’t want to overload server with a single query, but rather run smaller chunks and throttle requests if it’s too much…

BTW - what I guess you try to do is to implement some custom alerting on top of what Dynatrace does with AI. We work for better customization possibilities in that area - we’ll see what next year brings.

Anyway… 2000+ envs it pretty too much, but you probably already know that 😉

---

<div class="post-metadata">

**Author:** ![Radoslaw\_Szulgo](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radoslaw_szulgo/32/1977_2.png) [@Radoslaw\_Szulgo](https://community.dynatrace.com/u/Radoslaw_Szulgo)\
**Post date:** [July 1, 2020, 10:15am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/8 "2020-07-01T10:15:24Z")

</div>

OK - moved.

---

<div class="post-metadata">

**Author:** ![Radoslaw\_Szulgo](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radoslaw_szulgo/32/1977_2.png) [@Radoslaw\_Szulgo](https://community.dynatrace.com/u/Radoslaw_Szulgo)\
**Post date:** [July 1, 2020, 10:16am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/9 "2020-07-01T10:16:59Z")

</div>

Julius and I meant “Tokens” API that can be used to create automatically tokens for each environment. See my github example.

For the specific operation you should look at the Environment’s APIs.

---

<div class="post-metadata">

**Author:** ![irakli\_natsvlis](https://avatars.discourse-cdn.com/v4/letter/i/edb3f5/32.png) [@irakli\_natsvlis](https://community.dynatrace.com/u/irakli_natsvlis)\
**Post date:** [July 1, 2020, 10:30am UTC](https://community.dynatrace.com/t/dynatrace-managed-query-multiple-environments-for-alerts/19725/10 "2020-07-01T10:30:58Z")

</div>

OK, folks, thank you both.

Seems I need to take the path of Ansible/bash scripting way…
