diff --git a/content/en/synthetics/notifications/advanced_notifications.md b/content/en/synthetics/notifications/advanced_notifications.md index cd2214a5f61..30318b0d850 100644 --- a/content/en/synthetics/notifications/advanced_notifications.md +++ b/content/en/synthetics/notifications/advanced_notifications.md @@ -37,16 +37,6 @@ To display raw values without HTML escaping (for example, URLs, or HTTP response
Certain messaging integrations (such as Google) require triple braces {{{ around template variables to ensure proper formatting when the message is displayed. For example, you can use {{{synthetics.attributes.result.failure.message}}}.
-You can loop over lists (like steps or variables) or access items directly: - -```handlebars -{{list.2.name}} {{! third item }} -{{list.-1.status}} {{! last item }} -{{list[My Complex Name]url}} {{! use bracket notation for complex keys }} -{{list[My Complex Name]failure.code}} -{{list.abc-def-ghi}} {{! access via ID (case-insensitive) }} -``` - ### Human-readable formatting **Note**: All durations are in milliseconds. @@ -80,6 +70,9 @@ You can loop over lists (like steps or variables) or access items directly: ### Conditional alerting based on step ID ```handlebars +{{! +This alert uses the variable shortcut object `{{synthetics.failed_step}}` to match the step id. If the step id matches, notify the relevant recipient. +}} {{#is_exact_match synthetics.failed_step.id "svn-yrx-3xg"}} A backend-related step failed! @slack-backend-team @@ -98,55 +91,55 @@ Use `#each` to loop over dictionaries or lists. You can access: - `@key` → the current key (for dictionaries) - `@index`, `@first`, `@last` → loop metadata -#### Dictionary example: +### Use local variables in a notification ```handlebars -{{#each users}} - # User `{{@key}}` - Name: {{name}} - Permissions: {{permissions}} -{{/each}} - -Users: {{#each users}}`{{@key}}` ({{name}}){{#unless @last}}, {{/unless}}{{/each}} +{{! +The test is configured with three local variables. +The names of the variables are: APP_NAME, APP_URL, and APP_ENVIRONMENT. +The value of the variable can be accessed by passing its name in the config field like `{{synthetics.attributes.result.variables.config[].value}}` +}} +Application: {{synthetics.attributes.result.variables.config[APP_NAME].value}} +URL Tested: {{synthetics.attributes.result.variables.config[APP_URL].value}} +Environment: {{synthetics.attributes.result.variables.config[APP_ENVIRONMENT].value}} ``` -### Use local (config) variables in a notification +### Loop through the steps of a multistep API test ```handlebars -Synthetic Test Failed! - -Application: {{ synthetics.attributes.result.variables.config[APP_NAME].value }} -URL Tested: {{ synthetics.attributes.result.variables.config[APP_URL].value }} -Random value: {{ synthetics.attributes.result.variables.config[NAME].value }} +{{! Print out the details of each step }} +{{#each synthetics.attributes.result.steps}} +Step name: {{name}} +Step status: {{status}} +Step type: {{type}} -Test: {{ synthetics.attributes.test.name }} ({{ synthetics.attributes.test.id }}) -Failed step: {{ synthetics.failed_step.name }} -Location: {{ synthetics.attributes.location.id }} -Result: {{ synthetics.result_url }} + {{! Within each step, print out the details of the extracted variable }} + {{#each variables.extracted}} + Extracted variable name: {{ name }} + Extracted variable value: {{ val }} + {{/each}} -@your-email +{{/each}} ``` -
To loop through all config variables and print their values safely: - +### Loop through the steps of a browser test ```handlebars -{{#each synthetics.attributes.result.variables.config}} -- {{@key}}: {{#if this.secure}}[secure]{{else}}{{this.value}}{{/if}} -{{/each}} -``` +{{! Print out the details of each step }} +{{#each synthetics.attributes.result.steps}} -
+Step name: {{description}} +Step status: {{status}} +Step type: {{type}} -## Steps loop + {{! Print out the details of the extracted variable step }} + {{#is_match "type" "extractVariable"}} + Extracted variable name: {{ extractedValue.name }} + Extracted variable value: {{ extractedValue.value }} + {{/is_match}} -```handlebars -{{#each synthetics.attributes.result.steps}} -* Step name: {{description}} -* Step status: {{status}} -* Step type: {{type}} {{/each}} ``` ## Further Reading -{{< partial name="whats-next/whats-next.html" >}} \ No newline at end of file +{{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/synthetics/notifications/conditional_alerting.md b/content/en/synthetics/notifications/conditional_alerting.md index 52aeef831fc..16bdbd89e65 100644 --- a/content/en/synthetics/notifications/conditional_alerting.md +++ b/content/en/synthetics/notifications/conditional_alerting.md @@ -26,32 +26,78 @@ For more detailed information, see the }} \ No newline at end of file +{{< partial name="whats-next/whats-next.html" >}} diff --git a/content/en/synthetics/notifications/template_variables.md b/content/en/synthetics/notifications/template_variables.md index 99f7420e4fc..613dd103e9f 100644 --- a/content/en/synthetics/notifications/template_variables.md +++ b/content/en/synthetics/notifications/template_variables.md @@ -52,25 +52,34 @@ Test failed at step {{synthetics.failed_step.name}} with error: {{synthetics.fai {{< tabs >}} {{% tab "Test Info" %}} -`.test` -: Info about the test +`{{synthetics.attributes.test}}` +: The `test` object contains information about the test like its `name`, `type`, `subtype`, and `id` -`.test.id` -: Public ID (for example, `abc-def-ghi`) +`{{synthetics.attributes.test.name}}` +: The name of the test -`.test.type` +`{{synthetics.attributes.test.type}}` : Test type (for example, `api`) -`.test.subType` -: Subtype for API tests (for example, `http`) +`{{synthetics.attributes.test.subType}}` +: Subtype for API tests (for example, `http`, `dns`, and `multi`) + +`{{synthetics.attributes.test.id}}` +: The test's public ID (for example, `abc-def-ghi`) {{% /tab %}} {{% tab "Location" %}} -`.location.id` +`{{synthetics.attributes.location}}` +: The `location` object contains information about the location of where the test is run from + +`{{synthetics.attributes.location.id}}` : Location ID (for example, `aws:eu-central-1`) -`.location.privateLocation` +`{{synthetics.attributes.location.name}}` +: Name of the location (for example, `Frankfurt (AWS)`) + +`{{synthetics.attributes.location.privateLocation}}` : `true` for Private Locations {{% /tab %}} @@ -78,22 +87,25 @@ Test failed at step {{synthetics.failed_step.name}} with error: {{synthetics.fai Applies to browser and mobile tests. -`.device.id` +`{{synthetics.attributes.device}}` +: The `device` object contains information about the device on which the test is run on + +`{{synthetics.attributes.device.id}}` : Device identifier -`.device.name` +`{{synthetics.attributes.device.name}}` : Human-readable device name -`.device.type` +`{{synthetics.attributes.device.type}}` : Device type classification -`.device.resolution.width`, `.device.resolution.height` +`{{synthetics.attributes.device.width}}`, `{{synthetics.attributes.device.height}}` : Screen resolution dimensions -`.device.browser.type` +`{{synthetics.attributes.device.browser.type}}` : Browser type (browser tests only) -`.device.platform.name`, `.device.platform.version` +`{{synthetics.attributes.device.platform.name}}`, `{{synthetics.attributes.device.platform.version}}` : Platform information (mobile tests only) **Example values:** @@ -113,23 +125,29 @@ Applies to browser and mobile tests. {{% /tab %}} {{% tab "Result" %}} -`.result.id` +`{{synthetics.attributes.result}}` +: The `result` object contains information about the executed test run + +`{{synthetics.attributes.result.id}}` : Unique result ID -`.result.status` -: Test execution status +`{{synthetics.attributes.result.status}}` +: Test execution status (for example, `passed` or `failed`) -`.result.duration` +`{{synthetics.attributes.result.duration}}` : Test duration in milliseconds -`.result.testStartedAt`, `.result.testFinishedAt`, `.result.testTriggeredAt` +`{{synthetics.attributes.result.testStartedAt}}`, `{{synthetics.attributes.result.testFinishedAt}}`, `{{synthetics.attributes.result.testTriggeredAt}}` : Epoch timestamps in milliseconds -`.result.failure.message` -: Description of failure +`{{synthetics.attributes.result.failure}}` +: The `failure` object contains information about why the test failed -`.result.failure.code` -: Error code +`{{synthetics.attributes.result.failure.message}}` +: The failure message + +`{{synthetics.attributes.result.failure.code}}` +: The failure code **Example values:** ```json @@ -161,16 +179,16 @@ These are local variables configured for API tests or defined outside individual Located at `{{synthetics.attributes.result.variables.config}}`: -`.name` +`{{synthetics.attributes.result.variables.config.name}}` : Variable name -`.type` +`{{synthetics.attributes.result.variables.config.type}}` : Variable type -`.secure` +`{{synthetics.attributes.result.variables.config.secure}}` : Whether the variable value is obfuscated -`.value` +`{{synthetics.attributes.result.variables.config.value}}` : Variable value (non-obfuscated only) **Examples:** @@ -190,18 +208,18 @@ These are extracted variables whose value updates a global variable value. Available only for **successful test results** and **recovery notifications**. -Located at `result.variables.extracted`: +Located at `{{synthetics.attributes.result.variables.extracted}}`: -`.id` +`{{synthetics.attributes.result.variables.extracted.id}}` : Global variable ID -`.name` +`{{synthetics.attributes.result.variables.extracted.name}}` : Variable name -`.secure` +`{{synthetics.attributes.result.variables.extracted.secure}}` : Whether the variable value is obfuscated -`.val` +`{{synthetics.attributes.result.variables.extracted.val}}` : Variable value (note: uses `.val`, not `.value`) **Examples:** @@ -217,7 +235,7 @@ Located at `result.variables.extracted`: {{% /tab %}} {{% tab "Step extracted variables" %}} -For tests with steps, step data is contained in `.steps`. +For tests with steps, step data is contained in `{{synthetics.attributes.result.steps}}`. `.extractedValue.name` : Variable name @@ -319,7 +337,7 @@ Similar to standard API tests, the variables are listed in the `variables.extrac **General:** -`.startUrl` +`{{synthetics.attributes.result.startUrl}}` : URL from test configuration **Steps:**