1. Principle #
Trigger, tasks, conditions.
Structure #
| Trigger | Example |
|---|---|
| Event | A Davis problem opening, a security event, a custom event |
| Schedule | Every Monday at 8 a.m.: cost report; every hour: check |
| On demand | Button in an app or API call |
Tasks are chained with conditions ({{ result("query").records | length > 0 }}), loops, retries and delays.
2. Example #
Notifying with context.
JavaScript task #
import { execution } from '@dynatrace-sdk/automation-utils';
export default async function ({ execution_id }) {
const ex = await execution(execution_id);
const problem = ex.event(); // l'événement déclencheur
const critical = problem['event.category'] === 'AVAILABILITY';
return {
channel: critical ? '#astreinte' : '#ops',
text: `${problem['display_id']} : ${problem['event.name']} (${problem['affected_entity_ids']?.length ?? 0} entités)`,
};
}The next task (Slack or Teams) uses {{ result("decide").channel }} and {{ result("decide").text }}.
Good to know: The exact names of SDK functions and event fields depend on the version: start from the workflow templates offered in the app and adapt them.
3. Remediating safely #
Guardrails.
Rules #
- Start with reversible actions: restart a pod, clear a cache, add a replica.
- Add a human approval (wait task or button) for destructive actions.
- Limit frequency: a workflow that restarts a service in a loop makes the incident worse.
- Run workflows with a technical actor and minimal permissions.
Common mistake: A workflow runs with its actor's permissions: a workflow created by an administrator and editable by everyone is a privilege escalation.
