![]() |
VOOZH | about |
Use conditional templating to change messages, set notification handles, or override alert priority based on test results. This is especially useful when routing alerts to specific teams.
To ensure notifications are delivered properly, always include a notification handle in your conditional logic. Notifications are dropped if no handle is provided. Make sure to:
{{else}} to handle any unmatched scenarios.For more detailed information, see the Monitor documentation.
{{!
If a test triggers an alert for an API test and returns a 500 statuscode, notify the backend team.
}}
{{#is_alert}}
{{#is_exact_match "synthetics.attributes.result.response.statusCode" "500"}}@notify-slack-backend{{/is_exact_match}}
{{/is_alert}}
{{!
Use multiple is_exact_match conditions to display specific failure codes in your notification.
This example checks for DNS and INCORRECT_ASSERTION failure codes
}}
{{#if synthetics.attributes.result.failure}}
{{#is_exact_match "synthetics.attributes.result.failure.code" "DNS"}}
print out failure code: The failure code is DNS
{{/is_exact_match}}
{{#is_exact_match "synthetics.attributes.result.failure.code" "INCORRECT_ASSERTION"}}
print out failure code: The failure code is an INCORRECT ASSERTION
{{/is_exact_match}}
{{/if}}
{{!
If a test triggers an alert for browser or mobile tests, loop through each step and find the failed step.
If the failed step's description field matches Checkout, notify the recipient
}}
{{#is_alert}}
{{#each synthetics.attributes.result.steps}}
{{#is_match "status" "failed"}}
{{#is_match "description" "Checkout"}}@notify-slack-payments{{/is_match}}
{{/is_match}}
{{/each}}
{{/is_alert}}
{{!
This alert uses the {{synthetics.failed_step}} object which is a variable shortcut that points to the relevant step data contained in {{synthetics.attributes.result.steps}}.
If the test triggers an alert for browser or mobile tests, and if the failed step's description field matches Checkout, notify the recipient.
}}
{{#is_alert}}
{{#is_match "synthetics.failed_step.description" "Checkout"}}@notify-slack-payments{{/is_match}}
{{/is_alert}}
{{!
If a test triggers an alert for a multistep API test, loop through each step and find the failed step.
If the step's name matches the staging domain, set the priority to P2. Otherwise, set it to P4.
}}
{{#is_alert}}send a message to <name> @example@email.com
{{#each synthetics.attributes.result.steps}}
{{#is_match "status" "failed"}}
{{#is_match "name" "stagedomain"}}Stage domain failed. Overriding priority to P2.
{{override_priority 'P2'}}
{{else}}Dev domain failed. Overriding priority to P4{{override_priority 'P4'}}
{{/is_match}}
{{/is_match}}
{{/each}}
{{/is_alert}}
{{!
This alert uses the {{synthetics.failed_step}} object which is a variable shortcut that points to the relevant step data contained in `{{synthetics.attributes.result.steps}}`.
If the test triggers an alert for multistep API test and if the failed step's name field matches the domain, override the priority.
}}
{{#is_alert}}
{{#is_match "synthetics.failed_step.name" "stagedomain"}}Stage domain failed. Overriding priority to P2{{override_priority 'P2'}}
{{else}}Dev domain failed. Overriding priority to P4{{override_priority 'P4'}}
{{/is_match}}
{{/is_alert}}
Additional helpful documentation, links, and articles:
| |