Copy as Markdown[Open in ChatGPT](https://chatgpt.com/?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Fnotification-center%2Fdynamic-templating%2Ftera-syntax.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)[Open in Claude](https://claude.ai/new?q=Read%20https%3A%2F%2Fcoralogix.com%2Fdocs%2Fuser-guides%2Fnotification-center%2Fdynamic-templating%2Ftera-syntax.md%20and%20help%20me%20with%20my%20question%20about%20this%20Coralogix%20documentation%20page.)

# Tera syntax quick reference

Use this guide to build and troubleshoot Tera expressions in Notification Center. Tera syntax powers dynamic templating for connectors, presets, and routing rules.

## Basic syntax[​](#basic-syntax "Direct link to Basic syntax")

| Type            | Example                                                   | Description                       |
| --------------- | --------------------------------------------------------- | --------------------------------- |
| **Variable**    | `{{ alertDef.name }}`                                     | Displays the value of a variable. |
| **Conditional** | `{% if alert.status == "Triggered" %}...{% endif %}`      | Adds logic to control output.     |
| **Loop**        | `{% for i in alert.groups %}{{ i.priority }}{% endfor %}` | Iterates through a list.          |

## Comparison operators[​](#comparison-operators "Direct link to Comparison operators")

| Operator                | Example                         | Description              |
| ----------------------- | ------------------------------- | ------------------------ |
| `==`                    | `alert.highestPriority == "P1"` | Equal to                 |
| `!=`                    | `alert.status != "Resolved"`    | Not equal                |
| `>` , `<` , `>=` , `<=` | `alert.value > 80`              | Greater/less comparisons |

## Logical operators[​](#logical-operators "Direct link to Logical operators")

| Operator | Example                                                         | Description         |
| -------- | --------------------------------------------------------------- | ------------------- |
| `and`    | `alert.highestPriority == "P1" and alert.status == "Triggered"` | Both must be true   |
| `or`     | `alert.highestPriority == "P1" or alertDef.priority == "P2"`    | Either can be true  |
| `not`    | `not alert.status == "Resolved"`                                | Negates a condition |

## String tests[​](#string-tests "Direct link to String tests")

| Function             | Example                                         | Result                               |
| -------------------- | ----------------------------------------------- | ------------------------------------ |
| `is starting_with()` | `alertDef.name is starting_with("CPU")`         | `true` if the name begins with CPU   |
| `is containing()`    | `alertDef.description is containing("latency")` | `true` if the text includes the word |
| `is matching()`      | `alertDef.name is matching("(?i)^cpu")`         | Regex match                          |

## Filters[​](#filters "Direct link to Filters")

Filters transform or format values. Apply them with a pipe (`|`).

| Filter        | Example                                                  |
| ------------- | -------------------------------------------------------- |
| `default`     | `{{ alert.highestPriority \| default(value="P3") }}`     |
| `date`        | `{{ alert.timestamp \| date(format="%Y-%m-%d %H:%M") }}` |
| `json_encode` | `{{ get_context() \| json_encode(pretty=true) }}`        |
| `json_escape` | `{{ alert.groups \| json_escape }}`                      |
| `lower`       | `{{ alertDef.name \| lower }}`                           |
| `replace`     | `{{ alertDef.name \| replace(from=" ", to="_") }}`       |

## Boolean conditions in routing rules[​](#boolean-conditions-in-routing-rules "Direct link to Boolean conditions in routing rules")

Routing rule conditions must evaluate to `true` or `false`.<br /><!-- -->Do **not** wrap conditions in `{{ }}`, enter only the expression.

| Example                                       | Description                          |
| --------------------------------------------- | ------------------------------------ |
| `alert.highestPriority == "P1"`               | Routes only P1 alerts                |
| `alertDef.name is containing("CPU")`          | Routes alerts with “CPU” in the name |
| `alertDef.entityLabels.environment == "prod"` | Routes based on environment          |
| `true`                                        | Always triggers                      |

Note

* Use `{{ get_context() | json_encode(pretty=true) }}` to print all available variables.
* Wrap optional values with `default()` to avoid errors.
* Missing variables cause expressions to evaluate to `false`.
* Keep expressions readable: avoid complex logic in message fields.

## Next steps[​](#next-steps "Direct link to Next steps")

Build, validate, and troubleshoot Tera templates in [Tera usage and troubleshooting](https://coralogix.com/docs/docs/user-guides/notification-center/dynamic-templating/tera-usage/.md).
