# How to retrieve data from another tenant and display in chart through DQL

**URL:** <https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504>\
**Category:** DQL\
**Tags:** dql, dashboards, gen3\
**Created:** [December 30, 2025, 2:42am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504 "2025-12-30T02:42:02Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [December 30, 2025, 2:42am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/1 "2025-12-30T02:42:02Z")

</div>

We have created some charts which display the data from another tenant. In gen2 version, it can be configured like this:

 ![Hillman_0-1767062399659.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/3/f3ba3c415551a68a415092349797db3b8f36623b.png)

When I try to convert the chart to gen3 version, I am not sure how to use DQL to achieve this. Any suggestions?

---

<div class="post-metadata">

**Author:** ![olga\_wall](https://avatars.discourse-cdn.com/v4/letter/o/b5e925/32.png) [@olga\_wall](https://community.dynatrace.com/u/olga_wall)\
**Post date:** [December 30, 2025, 7:50am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/2 "2025-12-30T07:50:47Z")

</div>

Hi Hillman,

I haven’t done this myself yet but I think you can achieve this by querying the data from another tenant via API in a code tile on a gen3 dashboard.

---

<div class="post-metadata">

**Author:** ![Mohamed\_Hamdy](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Mohamed\_Hamdy](https://community.dynatrace.com/u/Mohamed_Hamdy)\
**Post date:** [December 30, 2025, 8:37am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/3 "2025-12-30T08:37:30Z")

</div>

Hi&nbsp;[@Hillman](https://community.dynatrace.com/user/63818)&nbsp;,

In Dynatrace 3rd Gen, a flexible approach to query data from another environment is to use a Dashboard/Notebook Code tile (external/remote environment data). The idea is to create a Platform Token in the remote environment with the required storage read scopes, store it in the local environment Credential Vault, and then call the remote query endpoint from the Code tile. You can use the sample below and simply replace the remote URL, Credential Vault, and adjust the DQL as needed.

```markup
import { credentialVaultClient } from "@dynatrace-sdk/client-classic-environment-v2";

async function fetchRemoteDql(credentialId, url, query) {
  const { token } = await credentialVaultClient.getCredentialsDetails({ id: credentialId });

  const response = await fetch(url, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
      Accept: "application/json",
      Authorization: `Bearer ${token}`,
    },
    body: JSON.stringify({
      query,
      requestTimeoutMilliseconds: 60000,
      enablePreview: true,
    }),
  });

  if (!response.ok) throw new Error(`HTTP ${response.status} ${response.statusText}`);
  return (await response.json()).result;
}

export default async function () {
  const credentialId = "CREDENTIALS_VAULT-XXXXXXX"; // your vault entry on the *local* env
  const url =
    "https://XXXXXXXX.apps.dynatrace.com/platform/storage/query/v1/query:execute";
  const query = `
timeseries usage = avg(dt.host.cpu.usage), by: { dt.entity.host }
| fieldsAdd entityName(dt.entity.host)
| sort arrayAvg(usage) desc
| limit 20
  `.trim();

  return await fetchRemoteDql(credentialId, url, query);
}

```

Note: make sure the remote environment url is added to the allowlist if it is configured to limit external requests from the environment.

> **[Allow external requests | Dynatrace Developer](https://developer.dynatrace.com/develop/guides/app-functions/allow-outbound-connections/)**
>
> Enable request to external hosts.

Regards,

Hamdy

---

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [December 30, 2025, 9:07am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/4 "2025-12-30T09:07:19Z")

</div>

Hi&nbsp;[@Mohamed\_Hamdy](https://community.dynatrace.com/user/4007),

I have tried with the DQL but I have found that it throws the following error.

```markup
{
  "error": {
    "code": 540,
    "message": "Execution crashed.",
    "details": {
      "logs": "403: The requested credential details cannot be accessed by the current user or entity.\n at CredentialVaultClient.getCredentialsDetails (file:///opt/sdk_modules/@dynatrace-sdk/client-classic-environment-v2@4/esm/index.js:6983:19)\n at eventLoopTick (ext:core/01_core.js:177:7)\n at async fetchRemoteDql (file:///script.ts:4:21)\n at async default (file:///script.ts:34:10)\n",
      "type": "UNCAUGHT_EXCEPTION",
      "message": "Uncaught (in promise) 403: The requested credential details cannot be accessed by the current user or entity.",
      "details": {
        "lineNumber": 6983,
        "startColumn": 19,
        "stack": "403: The requested credential details cannot be accessed by the current user or entity.\n at CredentialVaultClient.getCredentialsDetails (file:///opt/sdk_modules/@dynatrace-sdk/client-classic-environment-v2@4/esm/index.js:6983:19)\n at eventLoopTick (ext:core/01_core.js:177:7)\n at async fetchRemoteDql (file:///script.ts:4:21)\n at async default (file:///script.ts:34:10)"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Mohamed\_Hamdy](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Mohamed\_Hamdy](https://community.dynatrace.com/u/Mohamed_Hamdy)\
**Post date:** [December 30, 2025, 10:22am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/5 "2025-12-30T10:22:30Z")

</div>

Hello&nbsp;[@Hillman](https://community.dynatrace.com/user/63818)&nbsp;,

It looks like the failure is related to **Credential Vault access** (the code tile can’t read the credential)

Could you please confirm the following:

1. Did you create a **Platform token** in the remote environment (not an Environment API access token)? If yes, what scopes/permissions are enabled on that token?
2. How was the **Credential Vault** entry created on the local environment?

For more details on Platform Tokens, please refer to Dynatrace documentation: [Platform tokens — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/platform-tokens)

---

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [January 6, 2026, 3:45am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/6 "2026-01-06T03:45:43Z")

</div>

Hi&nbsp;[@Mohamed\_Hamdy](https://community.dynatrace.com/user/4007)&nbsp;,

Oh, I have mixed up the Platform token with the Environment API access token. Let me create one and try again. Regarding the scope, is it granting all storage:\*:read?

---

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [January 8, 2026, 3:23am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/7 "2026-01-08T03:23:38Z")

</div>

[@Mohamed\_Hamdy](https://community.dynatrace.com/user/4007)&nbsp;I have created a Platform Token with all “storage:\*:read” scopes in remote tenant, then create a credential vault entry in local tenant. However, it still returns the following error:

```markup
{
  "error": {
    "code": 540,
    "message": "Execution crashed.",
    "details": {
      "logs": "403: The requested credential details cannot be accessed by the current user or entity.\n at CredentialVaultClient.getCredentialsDetails (file:///opt/sdk_modules/@dynatrace-sdk/client-classic-environment-v2@4/esm/index.js:6983:19)\n at eventLoopTick (ext:core/01_core.js:177:7)\n at async fetchRemoteDql (file:///script.ts:4:21)\n at async default (file:///script.ts:34:10)\n",
      "type": "UNCAUGHT_EXCEPTION",
      "message": "Uncaught (in promise) 403: The requested credential details cannot be accessed by the current user or entity.",
      "details": {
        "lineNumber": 6983,
        "startColumn": 19,
        "stack": "403: The requested credential details cannot be accessed by the current user or entity.\n at CredentialVaultClient.getCredentialsDetails (file:///opt/sdk_modules/@dynatrace-sdk/client-classic-environment-v2@4/esm/index.js:6983:19)\n at eventLoopTick (ext:core/01_core.js:177:7)\n at async fetchRemoteDql (file:///script.ts:4:21)\n at async default (file:///script.ts:34:10)"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [January 8, 2026, 9:32am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/8 "2026-01-08T09:32:40Z")

</div>

[@Mohamed\_Hamdy](https://community.dynatrace.com/user/4007)&nbsp;I have found out the root cause now. I have to enable the following options in credential vault entry to make it work:

 ![Hillman_0-1767864752383.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/7/07c6d98aea516163599d655bd70dd24843e4149f.png)

---

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [January 13, 2026, 9:23am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/9 "2026-01-13T09:23:48Z")

</div>

[@Mohamed\_Hamdy](https://community.dynatrace.com/user/4007)&nbsp;Sorry that I have got one more question. If the original DQL contains “`”. How can I embed it into the code?

---

<div class="post-metadata">

**Author:** ![Mohamed\_Hamdy](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Mohamed\_Hamdy](https://community.dynatrace.com/u/Mohamed_Hamdy)\
**Post date:** [January 19, 2026, 1:14pm UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/10 "2026-01-19T13:14:26Z")

</div>

Hello&nbsp;[@Hillman](https://community.dynatrace.com/user/63818)&nbsp;,

If your original DQL contains a backtick **`** and you’re embedding it in the code using a JavaScript template literal (also delimited by backticks), you just need to **escape the backtick inside the DQL**.

Use &nbsp;(backslash + backtick).

Example:

```javascript
const query = `
fetch logs
| filter contains(content, \`some-value\`)
| limit 20
`.trim();

```

---

<div class="post-metadata">

**Author:** ![joyce-regions](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@joyce-regions](https://community.dynatrace.com/u/joyce-regions)\
**Post date:** [January 21, 2026, 7:36pm UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/11 "2026-01-21T19:36:12Z")

</div>

follow the question, can you help me with the query? there is lookup to join two table in this. I have result when i run two query separate but when I combine them with lookup, there is no result. but they support have results as

export default async function() {  
const credentialId = “CREDENTIALS\_VAULT-A80F208D9C83954A”; // Replace with your credential vault ID.  
const url = “https://{environmentid}.apps.dynatrace.com/platform/storage/query/v1/query:execute”; // Replace with API URL.  
const query =  
load “/lookups/2026Wave1-4”  
| fieldsAdd Servers=lower(Name)  
| fieldsAdd tenant= if(IN(Environment,{“Production”, “DisasterRecovery”}), “Production”  
,else: if(In(Environment,{“Test”,“QualityAssurance”,“QAEnvironment”}),“Non-Prod”))  
| filterout In(Environment,{“Production”, “DisasterRecovery”})  
|lookup [fetch dt.entity.host  
|fieldsAdd hostname = entity.name, hostGroupName, installerVersion  
| parse hostname, “”“LD:Host ‘.’”“”  
| fields Host = lower(Host), entity.name, hostGroupName], sourceField:Servers,lookupField:Host, prefix:“DT-”  
| fieldsAdd Status = if(`Servers` == `DT-Host`, “Dynatrace”, else:“need onboard”)  
//|filter contains(`AppCode`,“FDP”)  
| filter isNotNull(tenant)  
// |filter contains(`Wave`,“”)  
| summarize by:{AppCode, Environment, Tier,Wave, tenant, SRE}, {  
Plan=countif(Status==“need onboard”),  
Installed=countif(Status == “Dynatrace”),  
total=count()

}  
//| fieldsAdd Need\_Onboard = (toDouble(Plan) / toDouble(total)) \* 100  
| fieldsAdd Onboard\_status = (toDouble(Installed) / toDouble(total)) \* 100  
| fieldsAdd Status = if(Onboard\_status == 100, “Done”,  
else: if(Onboard\_status \> 0, “In-Progress”,  
else: “Not\_started”))  
";

---

<div class="post-metadata">

**Author:** ![Mohamed\_Hamdy](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Mohamed\_Hamdy](https://community.dynatrace.com/u/Mohamed_Hamdy)\
**Post date:** [January 21, 2026, 9:28pm UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/12 "2026-01-21T21:28:31Z")

</div>

Try this, I’ve only corrected the backticks/field reference to avoid parsing issues. Please let me know if it works on your side.

```javascript
const query = `
load "/lookups/2026Wave1-4"
| fieldsAdd Servers=lower(Name)
| fieldsAdd tenant= if(IN(Environment,{"Production", "DisasterRecovery"}), "Production"
,else: if(In(Environment,{"Test","QualityAssurance","QAEnvironment"}),"Non-Prod"))
| filterout In(Environment,{"Production", "DisasterRecovery"})
|lookup [fetch dt.entity.host
  |fieldsAdd hostname = entity.name, hostGroupName, installerVersion
  | parse hostname, """LD:Host '.'"""
  | fields Host = lower(Host), entity.name, hostGroupName
], sourceField:Servers, lookupField:Host, prefix:"DT-"
| fieldsAdd Status = if(Servers == \`DT-Host\`, "Dynatrace", else:"need onboard")
| filter isNotNull(tenant)
| summarize by:{AppCode, Environment, Tier, Wave, tenant, SRE}, {
    Plan=countif(Status=="need onboard"),
    Installed=countif(Status == "Dynatrace"),
    total=count()
}
| fieldsAdd Onboard_status = (toDouble(Installed) / toDouble(total)) * 100
| fieldsAdd Status = if(Onboard_status == 100, "Done",
  else: if(Onboard_status > 0, "In-Progress",
  else: "Not_started"))
`.trim();

```

---

<div class="post-metadata">

**Author:** ![Hillman](https://avatars.discourse-cdn.com/v4/letter/h/439d5e/32.png) [@Hillman](https://community.dynatrace.com/u/Hillman)\
**Post date:** [January 22, 2026, 1:43am UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/13 "2026-01-22T01:43:17Z")

</div>

[@Mohamed\_Hamdy](https://community.dynatrace.com/user/4007)&nbsp;I have tried to use backslash to escape but the query still fails.&nbsp;☹️

---

<div class="post-metadata">

**Author:** ![alicia\_pepper](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/alicia_pepper/32/7241_2.png) [@alicia\_pepper](https://community.dynatrace.com/u/alicia_pepper)\
**Post date:** [March 16, 2026, 2:12pm UTC](https://community.dynatrace.com/t/how-to-retrieve-data-from-another-tenant-and-display-in-chart-through-dql/54504/14 "2026-03-16T14:12:45Z")

</div>

Any plans to make this as easy as it was in Gen 2 / Classic dashbaords?&nbsp; this is not very user friendly for the end users in converting and creating!!
