30 Dec 2025 02:42 AM
We have created some charts which display the data from another tenant. In gen2 version, it can be configured like this:
When I try to convert the chart to gen3 version, I am not sure how to use DQL to achieve this. Any suggestions?
30 Dec 2025 08:37 AM - edited 30 Dec 2025 08:43 AM
Hi @Hillman ,
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.
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.
https://developer.dynatrace.com/develop/app-functions/allow-outbound-connections/
Regards,
Hamdy
30 Dec 2025 09:07 AM
Hi @Mohamed_Hamdy,
I have tried with the DQL but I have found that it throws the following error.
{
"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)"
}
}
}
}
30 Dec 2025 10:22 AM
Hello @Hillman ,
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:
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?
How was the Credential Vault entry created on the local environment?
For more details on Platform Tokens, please refer to Dynatrace documentation: https://docs.dynatrace.com/docs/shortlink/platform-tokens
Featured Posts