Nicolas, please also vote for this:
Hello everyone, this is my solution to display problems based on the management zone.
export default async function () {
const baseUrl = "https://{environmentid}.live.dynatrace.com/api/v2/problems";
const headers = {
"Authorization": "Api-Token YOUR_API_TOKEN",
"Content-Type": "application/json"
};
async function fetchProblems() {
const queryParams = new URLSearchParams({
pageSize: "50",
from: "now-30d",
to: "now",
problemSelector: 'status("OPEN")'
});
const response = await fetch(`${baseUrl}?${queryParams.toString()}`, {
method: "GET",
headers
});
const result = await response.json();
return result.problems || [];
}
try {
const problems = await fetchProblems();
const filtered = problems
.filter(p =>
(p.managementZones || []).some(zone => zone.name === "YOUR_MANAGEMENT_ZONE")
)
.map(p => ({
Problem: p.displayId,
Title: p.title,
ManagementZones: p.managementZones.map(mz => mz.name)
}));
return filtered;
} catch (error) {
console.error("❌ Error fetching problems:", error);
return `Error: ${error.message}`;
}
}
This a useful function. You may consider protecting your token as you do not want to expose it when you save your code somewhere. It may be safer to extract the token from the header after the call or you do encrypt it using a fixed secret which you can extract from a meta fixed environment, use a local simple encrypt function. Let me know if you have a solution other wise I will provide my simple encrypt solution. The best is to extract the token from the header of the AppFunction call but I do not know how to do that at the moment, I can only extract the PayLoad, and I have no way to extract the header i-on its own. Hope this is helpful.
Yes, first you need to store the token in the Credential Vault, and then use it like this in your workflow code:
import { credentialVaultClient } from "@dynatrace-sdk/client-classic-environment-v2";
export default async function () {
const credentialId = "ID_CREDENTIALS_VAULT";
const credential = await credentialVaultClient.getCredentialsDetails({
id: credentialId
});
const baseUrl = "https://{environmentid}.live.dynatrace.com/api/v2/problems";
const headers = {
"Authorization": credential.token,
"Content-Type": "application/json"
};
... rest of code
};
I’m using Workflows and that way it works, however, you could try a .type?.token according to what the documentation says."
Hello,
We are trying to apply segments to a basic dashboard (response time split by service). The segments are configured to split the data by environnement (prod, qual, preprod…). We are using tags on host, process and services.
Unfortunately, this configuration doesn’t display anything on the dashboard when it is applied. Do you know what could be missing ?
hi @JMBMinint
You’re assuming that filtering on entities would imply that the filter is also applied to the data that is linked to entities, as it is the case with management zones. With data stored in Grail, this is not the case. You have to include in the segment definition also the “data”.
We just released a set of best practices on how to transition from management zones to segments. Please have a look at it to get some inspiration on what this can look like for you: https://docs.dynatrace.com/docs/shortlink/transition-guide-segments
Best,
Sini
Hi Sini,
Thanks for your reply, the application we are monitoring is in app only mode and run in a Heroku base environment. Is it a cloud-native scenario? If yes, which environment variables I have to set? Here is the one already setted => DT_CUSTOM_PROP_HEROKU_APP=“app=CPERFRONT env=PROD”
Best regards,
JM
Hi JM,
Yes, your scenario is a cloud native one.
I am not sure where you found the DT_CUSTOM_PROP_HEROKU_APP environment variable; what we have in our documentation is DT_CUSTOM_PROP without the suffix. Having DT_CUSTOM_PROP or DT_TAGS environment variables causes host and process-level metrics sent by the particular OneAgent to have the defined key value combinations available in the environment variable as metric dimensions and values in Grail.
Unfortunately, the environment variables don’t enrich spans. But the OneAgent is picking up for spans the environment variable OTEL_RESOURCE_ATTRIBUTES.
If you are using the traces on grail capability and want the span data to be enriched in grail with your custom fields then you can do this like follows.
OTEL_RESOURCE_ATTRIBUTES="app=CPERFRONT,env=PROD"
The semantic is a bit different, comma instead of space.
We are currently working to streamline OneAgent side enrichment when using environment variables so in future setting one environment variable will be sufficient.
Best
Sini
Hi Sini,
I got this environnement variable from the DT support.
So if I put these two variables, I should be good ?
DT_CUSTOM_PROP=“app=CPERFRONT,env=PROD”
OTEL_RESOURCE_ATTRIBUTES=“app=CPERFRONT,env=PROD”
Best regards,
JM
Yes if you add those two environment variables, you should be good.
Please let me know the outcome.
Best,
Sini
Hi Sini,
We implemented the two variables, but I still don’t know how to configure the data fields in the segment configuration. Nothing changes overthere. Do I need a variable?
Best regards,
JM
Hi JM,
Yes, you need a variable. This would be the definition of the segment variable
fetch metric.series
| filter isNotNull(app)
| fields app , metadata = concat("[ENVIRONMENT]app:",app)
And this is how the segment definition could look like
You have also to propagate your variables (app & env) to Davis problems. In settings, you need to configure your tag to be propagated to Davis problems.
- Go to Settings > Analyze and alert > Root cause analysis > Problem fields.
- Select New field. (app & env)
Best,
Sini
Hi Sini,
Thanks for your reply ! The DQL request return nothing. Is there something I have to do to so that the environment variable are available in Grail ?
Regards
JM
Regards,
Jean-Michel
Can you try to set the environment variables without double quotes for the OTEL_RESOURCE_ATTRIBUES env var? In some deployment environments, double quotes might cause problems.
OTEL_RESOURCE_ATTRIBUTES=app=CPERFRONT,env=PROD
For the DT_CUSTOM_PROP one, you have to use “blank” as a field separator.
DT_CUSTOM_PROP=“app=CPERFRONT env=PROD”
Currently, we’re working on improving documentation about how to set these environment variables. Just looked up the first draft of this documentation.
Best,
Sini
Updated link is Upgrade from management zones to segments — Dynatrace Docs for those who need it since the shortlink doesn’t work anymore.
Hi,
What would you suggest for a new customer to use to separate dev and prod environments by aws account id. He also wants to have access control - e.g. one group of people to access dev and other prod. - Management zones + Segments (for Notebooks and Dashbords), Segments + some specific configuration in Account Management, … ?
Regards, Deni
Any plans on improving the documentation for how to migrate from MZ => Segments for dashboards?
The existing documentation is quite lacking.




