15 Jan 2026 02:37 AM - edited 15 Jan 2026 02:40 AM
The background of my question come from another post when I try to retrieve data from remote tenant and display in chart. (I am not able to include the post link here as the forum keep throwing error and remove the link and the code block below)
A nice person has suggested a workaround for it:
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://{environmentid}.apps.dynatrace.com/platform/storage/query/v1/query:execute";
const query = `
QUERY
`.trim();
return await fetchRemoteDql(credentialId, url, query);
}
However, my DQL also contains "`" which cause the query to crash during execution.
confluent_kafka_server_received_bytes = avg(confluent_kafka_server_received_bytes, filter: { in(`dt.entity.prometheus:confluent_kafka_cluster`, classicEntitySelector("type(prometheus:confluent_kafka_cluster),entityName.equals(\"cluster_name\")")) }), by: { `dt.entity.prometheus:confluent_kafka_cluster` }
| fieldsAdd entityName(`dt.entity.prometheus:confluent_kafka_cluster`)
| sort arrayAvg(confluent_kafka_server_received_bytes) desc
Is there any way to escape the "`" within "`"?
15 Jan 2026 02:40 AM
The link to the post is in here:
Solved: How to retrieve data from another tenant and display in chart through DQL - Dynatrace Commun...
Featured Posts