Esta página aún no está disponible en español. Estamos trabajando en su traducción.
Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.

Overview

You can customize Synthetic monitor messages using handlebars templating. The following examples cover advanced techniques such as comments, list access, conditions, and iterations.

Note: Always test your syntax directly in the monitor message editor, as template behavior may vary slightly across versions.

Comments

Use comments to explain what the template is doing. Comments are removed from the final rendered message.

{{! This is a comment }}
{{!
This is a
multi-line comment
}}

Raw strings

To display raw values without HTML escaping (for example, URLs, or HTTP responses in code blocks), use triple curly braces:

{{{my_var}}}

Accessing list data

You can loop over lists (like steps or variables) or access items directly:

{{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.

  • Durations:

    {{eval "synthetics.attributes.result.duration/1000"}}
    
  • Data Sizes:

    {{eval "humanize_bytes(bodySize)"}}
    

Conditions

Use #if, #is_match, and #is_exact_match for logic-based rendering.

Boolean check:

{{#if synthetics.attributes.variable.config.CONFIG_VAR.secure}}
  The CONFIG_VAR variable is obfuscated
{{else}}
  The CONFIG_VAR variable isn't obfuscated
{{/if}}

Conditional alerting based on step ID

{{#is_exact_match synthetics.failed_step.id "svn-yrx-3xg"}}
  A backend-related step failed!
  @slack-backend-team
{{else}}
  Another step failed, probably Frontend related
  @slack-frontend-team
{{/is_exact_match}}
Use #if over #is_exact_match for checking if a variable is empty or unset.

Iteration

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:

{{#each users}}
  # User `{{@key}}`
  Name: {{name}}
  Permissions: {{permissions}}
{{/each}}

Users: {{#each users}}`{{@key}}` ({{name}}){{#unless @last}}, {{/unless}}{{/each}}

Steps loop

{{#each synthetics.attributes.result.steps}}
* Step name: {{description}}
* Step status: {{status}}
* Step type: {{type}}
{{/each}}

Further Reading