08 Jan 2025 12:09 PM
Hello, am I missing a MZ selection or is there a TAG I can use instead. Could also be that this is all and the rest is up to the workflow?
KR Henk
Solved! Go to Solution.
10 Jan 2025 07:12 AM
Unfortunately, Management Zone Filtering is not available for (Davis) Event Triggers in Workflows.
If you already know that you're looking for a specific tag, that would be an option.
If not, filtering should be doable in a follow-up task within the same Workflow with a DQL task (or maybe using "Run JavaScript"). Please have a look at https://community.dynatrace.com/t5/Dashboarding/Filter-by-Management-Zone-using-DQL/m-p/232272/highl... for inspiration.
10 Jan 2025 09:00 AM
//i Christian thanks for your reply maybe below code can help someone else
//Based on effected entities, and returning ManagementZone if found in any
import { monitoredEntitiesClient } from "@dynatrace-sdk/client-classic-environment-v2";
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
const filterMZ = "***Fill in MZ name to filter***";
const ex = await execution(execution_id);
const eventData = ex.event();
console.log(eventData);
// Extracting entities from event
for (const My_entity of eventData.affected_entity_ids) {
console.log(`Processing element: ${My_entity}`);
try {
// Retrieve entity data from Dynatrace
let entityData = await monitoredEntitiesClient.getEntity({
entityId: My_entity
});
// Check if any management zone has the specific name
for (const zone of entityData.managementZones) {
console.log(zone.name);
if (zone.name === filterMZ) {
return filterMZ;
}
}
} catch (error) {
console.error(`Failed to retrieve data for element: ${My_entity}`, error);
}
}
return "";
}