From 20cb3111f27bab81e5b88daa1935d9212078648f Mon Sep 17 00:00:00 2001 From: mkhamessi Date: Tue, 14 Oct 2025 17:18:48 +0100 Subject: [PATCH 1/2] docs(synthetics/notifications): use Local (Config) variables in notification emails; add example + loop --- content/en/synthetics/notifications/_index.md | 11 ++++++++ .../notifications/advanced_notifications.md | 25 +++++++++++++++++++ .../notifications/template_variables.md | 5 ++++ 3 files changed, 41 insertions(+) diff --git a/content/en/synthetics/notifications/_index.md b/content/en/synthetics/notifications/_index.md index 3537fad8bbd4d..4829c95f4dcda 100644 --- a/content/en/synthetics/notifications/_index.md +++ b/content/en/synthetics/notifications/_index.md @@ -24,6 +24,17 @@ You can customize notifications using: - **[Templated variables][2]**: Enrich your notifications with dynamic content. - **[Conditional logic][3]**: Adapt alert messages across different test types and workflows. - **[Advanced usage][4]**: Structure complex messages using handlebars templating. +### Display Local (Config) Variables + +You can reference variables defined in your API or step-based tests directly in notification messages. + +- Local (Config) variables: `{{synthetics.attributes.result.variables.config}}` + +{{< further-reading >}} +- [Synthetic Monitoring Template Variables](/synthetics/notifications/template_variables/) +- [Synthetic Monitoring Advanced Notifications](/synthetics/notifications/advanced_notifications/) +{{< /further-reading >}} + - **[Custom notification display](#display-custom-notifications-message)**: Show only your custom message without default enriched content. - **[Simulate notifications](#simulate-notifications)**: Test your notification messages by sending simulated notifications. diff --git a/content/en/synthetics/notifications/advanced_notifications.md b/content/en/synthetics/notifications/advanced_notifications.md index e18d348e8f3d9..36bb843a523ba 100644 --- a/content/en/synthetics/notifications/advanced_notifications.md +++ b/content/en/synthetics/notifications/advanced_notifications.md @@ -91,6 +91,31 @@ You can loop over lists (like steps or variables) or access items directly:
Use #if over #is_exact_match for checking if a variable is empty or unset.
### Iteration +#### Example: Prefer step-extracted value, then fallback to extracted globals, then config + +```handlebars +#### Example: Use Local (Config) variables in a notification + +```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 }} + +Test: {{ synthetics.attributes.test.name }} ({{ synthetics.attributes.test.id }}) +Failed step: {{ synthetics.failed_step.name }} +Location: {{ synthetics.attributes.location.id }} +Result: {{ synthetics.result_url }} + +@your-email + +> Tip: Loop all config variables and print safe values: +{{#each synthetics.attributes.result.variables.config}} +- {{@key}}: {{#if this.secure}}[secure]{{else}}{{this.value}}{{/if}} +{{/each}} + + Use `#each` to loop over dictionaries or lists. You can access: diff --git a/content/en/synthetics/notifications/template_variables.md b/content/en/synthetics/notifications/template_variables.md index 33de07d7f81a9..a1a0878f9b587 100644 --- a/content/en/synthetics/notifications/template_variables.md +++ b/content/en/synthetics/notifications/template_variables.md @@ -10,6 +10,11 @@ further_reading: tag: "Documentation" text: "Learn more about monitor templates" --- +{{< callout >}} +**Local (Config) variables** are available at `result.variables.config`. Each entry has `name`, `type`, `secure`, and (when not secure) `value`. +Access a specific variable with bracket notation, for example: +`{{ synthetics.attributes.result.variables.config[APP_NAME].value }}`. +{{< /callout >}} ## Overview From 7495c73e43c0834c19a110144da750736e53a0ac Mon Sep 17 00:00:00 2001 From: aliciascott Date: Wed, 15 Oct 2025 13:46:01 -0600 Subject: [PATCH 2/2] fix callout, add links to avoid redundant info --- content/en/synthetics/notifications/_index.md | 14 ++---- .../notifications/advanced_notifications.md | 46 ++++++++++--------- .../notifications/template_variables.md | 7 +-- 3 files changed, 29 insertions(+), 38 deletions(-) diff --git a/content/en/synthetics/notifications/_index.md b/content/en/synthetics/notifications/_index.md index 4829c95f4dcda..a0db9f45235ef 100644 --- a/content/en/synthetics/notifications/_index.md +++ b/content/en/synthetics/notifications/_index.md @@ -24,20 +24,11 @@ You can customize notifications using: - **[Templated variables][2]**: Enrich your notifications with dynamic content. - **[Conditional logic][3]**: Adapt alert messages across different test types and workflows. - **[Advanced usage][4]**: Structure complex messages using handlebars templating. -### Display Local (Config) Variables - -You can reference variables defined in your API or step-based tests directly in notification messages. - -- Local (Config) variables: `{{synthetics.attributes.result.variables.config}}` - -{{< further-reading >}} -- [Synthetic Monitoring Template Variables](/synthetics/notifications/template_variables/) -- [Synthetic Monitoring Advanced Notifications](/synthetics/notifications/advanced_notifications/) -{{< /further-reading >}} - - **[Custom notification display](#display-custom-notifications-message)**: Show only your custom message without default enriched content. - **[Simulate notifications](#simulate-notifications)**: Test your notification messages by sending simulated notifications. +**Note**: For information about accessing local (config) variables, see the [Variables][6] section. + ## Pre-filled monitor messages Synthetic Monitoring provides pre-filled messages with metadata such as: @@ -258,5 +249,6 @@ Simulated notifications include **[TEST]** in their subject lines and use a defa [3]: /synthetics/notifications/conditional_alerting [4]: /synthetics/notifications/advanced_notifications [5]: /monitors/notifications +[6]: /synthetics/notifications/template_variables/?tab=testinfo#variables diff --git a/content/en/synthetics/notifications/advanced_notifications.md b/content/en/synthetics/notifications/advanced_notifications.md index 36bb843a523ba..cd2214a5f61a0 100644 --- a/content/en/synthetics/notifications/advanced_notifications.md +++ b/content/en/synthetics/notifications/advanced_notifications.md @@ -91,10 +91,26 @@ You can loop over lists (like steps or variables) or access items directly:
Use #if over #is_exact_match for checking if a variable is empty or unset.
### Iteration -#### Example: Prefer step-extracted value, then fallback to extracted globals, then config + +Use `#each` to loop over dictionaries or lists. You can access: + +- `this` → the current item +- `@key` → the current key (for dictionaries) +- `@index`, `@first`, `@last` → loop metadata + +#### Dictionary example: ```handlebars -#### Example: Use Local (Config) variables in a notification +{{#each users}} + # User `{{@key}}` + Name: {{name}} + Permissions: {{permissions}} +{{/each}} + +Users: {{#each users}}`{{@key}}` ({{name}}){{#unless @last}}, {{/unless}}{{/each}} +``` + +### Use local (config) variables in a notification ```handlebars Synthetic Test Failed! @@ -109,32 +125,18 @@ Location: {{ synthetics.attributes.location.id }} Result: {{ synthetics.result_url }} @your-email +``` -> Tip: Loop all config variables and print safe values: -{{#each synthetics.attributes.result.variables.config}} -- {{@key}}: {{#if this.secure}}[secure]{{else}}{{this.value}}{{/if}} -{{/each}} - - - -Use `#each` to loop over dictionaries or lists. You can access: - -- `this` → the current item -- `@key` → the current key (for dictionaries) -- `@index`, `@first`, `@last` → loop metadata - -#### Dictionary example: +
To loop through all config variables and print their values safely: ```handlebars -{{#each users}} - # User `{{@key}}` - Name: {{name}} - Permissions: {{permissions}} +{{#each synthetics.attributes.result.variables.config}} +- {{@key}}: {{#if this.secure}}[secure]{{else}}{{this.value}}{{/if}} {{/each}} - -Users: {{#each users}}`{{@key}}` ({{name}}){{#unless @last}}, {{/unless}}{{/each}} ``` +
+ ## Steps loop ```handlebars diff --git a/content/en/synthetics/notifications/template_variables.md b/content/en/synthetics/notifications/template_variables.md index a1a0878f9b587..2012c0440a07e 100644 --- a/content/en/synthetics/notifications/template_variables.md +++ b/content/en/synthetics/notifications/template_variables.md @@ -10,11 +10,6 @@ further_reading: tag: "Documentation" text: "Learn more about monitor templates" --- -{{< callout >}} -**Local (Config) variables** are available at `result.variables.config`. Each entry has `name`, `type`, `secure`, and (when not secure) `value`. -Access a specific variable with bracket notation, for example: -`{{ synthetics.attributes.result.variables.config[APP_NAME].value }}`. -{{< /callout >}} ## Overview @@ -24,6 +19,8 @@ Template variables allow you to insert dynamic values from your test results and Test failed at step {{synthetics.failed_step.name}} with error: {{synthetics.failed_step.failure.message}}. ``` +**Note**: For information about accessing local (config) variables, see the [Variables](#variables) section. + ### Common variable shortcuts `{{synthetics.failed_step.name}}`