> For the complete documentation index, see [llms.txt](https://docs.ilert.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ilert.com/alerting/configure-alerting/event-flows/transform-event.md).

# Transform event

Rewrite an event inside an event flow before it is branched on or routed: set, copy, map, template, merge and append fields, for every event or only those that match a condition.

A **Transform event** node rewrites the event as it passes through an [event flow](https://docs.ilert.com/alerting/configure-alerting/event-flows.md). Every node after it works with the new values: a **Branch** condition tests them, and **Route to alert source** hands the rewritten event to the alert source.

Use it to fix an event before anyone is paged by it:

* Turn a tool's own severity words into an ilert priority.
* Put the environment in the summary, so the alert says where it comes from.
* Add a label or a runbook link that the tool never sends.

The node is available on every account that has event flows.

## Add a Transform event node

{% stepper %}
{% step %}

### Open the flow in the editor

Go to **Alerting** → **Event flows**, open the flow and click **Edit**.
{% endstep %}

{% step %}

### Add the node

Click the **+** where the event should be rewritten and choose **Transform event**. Right below **Incoming event** is the usual place, because then every later node sees the result. The node's settings open at once.
{% endstep %}

{% step %}

### Add rules

Click **Add rule**, or one of the **Quick start** chips to begin from a prepared rule. For each rule, choose a **Target field**, the field the rule writes, and an **Operation**, then fill in the value. Rules run from top to bottom; the arrows on a rule move it up or down.
{% endstep %}

{% step %}

### Limit it to some events (optional)

Check **Transform events that meet the following conditions** and build the condition. Events that do not match pass through the node unchanged.
{% endstep %}

{% step %}

### Save the flow

Click **Close**, then **Save**. **Close** only keeps your rules in the editor; the flow does not change until you save it. If ilert rejects a rule, the node shows an error icon on the canvas, and hovering over it gives the reason.
{% endstep %}
{% endstepper %}

To confirm it works, send a test event to the flow and open its logs. The node's entry lists every field it changed. See [Check what a node changed](#check-what-a-node-changed).

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2Fgit-blob-72885a81a3226027a717a7915fde8df55f945dd2%2Fevent-flow-transform-settings.png?alt=media" alt="The Transform event settings of the Acme Checkout normalization flow: an Optional title field; Quick start chips Prefix summary, Set priority, Add labels, Add links and Add details; an unchecked box Transform events that meet the following conditions; and a rule named Priority from severity with Target field context.event.priority, Operation Map values, Source field context.event.customDetails.severity, a table mapping critical and error to HIGH and warning to LOW, and Default value LOW."><figcaption><p>A <strong>Map values</strong> rule. Every rule names the field it writes and the operation it uses.</p></figcaption></figure>

### Quick start

Each chip adds one rule, which you then complete.

| Chip               | Adds a rule that                                                                                                                                                                                                                              |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Prefix summary** | Uses **Template** on `context.event.summary`, prefilled with `[PREFIX] {{context.event.summary}}`                                                                                                                                             |
| **Set priority**   | Uses **Set value** on `context.event.priority`                                                                                                                                                                                                |
| **Add labels**     | Uses **Merge properties** on `context.event.labels`                                                                                                                                                                                           |
| **Add links**      | Uses **Add to array** on `context.event.links`                                                                                                                                                                                                |
| **Add details**    | Writes a table of properties into `context.event.details`, which holds text. ilert rejects this rule when you save. To add custom details, change **Target field** to `context.event.customDetails` and **Operation** to **Merge properties** |

## How the node runs

1. If the node has a condition, ilert evaluates it once, before any rule. An event that does not match passes through unchanged, and the log shows **Skipped**. A condition that fails to evaluate also lets the event pass unchanged, without a **Skipped** entry.
2. The rules run from top to bottom. Each rule sees what the rules above it wrote: a rule that reads `context.event.summary` gets the summary an earlier rule rewrote.
3. The next node gets the rewritten event.

A rule that fails does not stop the node or the flow. The log records an error that names the rule, and the next rule runs. Some mistakes are not errors and change nothing, such as copying from a field the event does not have. When a rule seems to do nothing, check the log.

Two fields can be overwritten after the node. If a **Route to alert source** node overrides the escalation policy or the notification priority, it replaces the `routingKey` or `priority` a transform set.

## Fields you can write

**Target field** offers the event's own fields under **Event properties**, followed by the custom fields found in the sample payloads of the flow's integrations. You can also type a path.

| Target field                                                                                           | Holds                                     | Operations                                                                                                                                   |
| ------------------------------------------------------------------------------------------------------ | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `context.event.summary`, `context.event.details`, `context.event.alertKey`, `context.event.routingKey` | Text                                      | **Set value**, **Copy from field**, **Template**, **Map values**                                                                             |
| `context.event.eventType`                                                                              | `ALERT`, `ACCEPT` or `RESOLVE`            | **Set value**, **Copy from field**, **Map values**                                                                                           |
| `context.event.priority`                                                                               | `HIGH` or `LOW`                           | **Set value**, **Copy from field**, **Map values**                                                                                           |
| `context.event.severity`                                                                               | `1` to `5`, shown as **SEV1** to **SEV5** | **Set value**, **Copy from field**, **Map values**                                                                                           |
| `context.event.labels`                                                                                 | Key-value pairs                           | **Set value**, **Merge properties**                                                                                                          |
| `context.event.customDetails`                                                                          | The event's custom payload                | **Set value**, **Merge properties**                                                                                                          |
| `context.event.customDetails.<path>`                                                                   | Any value                                 | All six, unless the path contains the name of an event field, such as `severity` or `labels`. Then the editor offers that field's operations |
| `context.event.links`, `context.event.images`, `context.event.services`, `context.event.comments`      | Lists                                     | **Set value**, **Add to array**                                                                                                              |

A few things to know about these fields:

* **Event type changes what the event does.** `ACCEPT` and `RESOLVE` act on the open alert with the same alert key instead of creating one. A value that is not an event type is skipped and logged as an error.
* **Priority must end up exactly `HIGH` or `LOW`, in capitals.** The node writes whatever a rule produces without checking or converting it, so check your mappings. A priority the event leaves the flow with replaces the alert source's own priority setting.
* **Severity must be a number from 1 to 5.** Any other value is skipped and logged as an error.
* **You cannot write a single label.** `context.event.labels.team` is not a valid target: **Merge properties** adds labels and **Set value** replaces all of them.
* **Custom details paths are created as needed.** **Set value** on `context.event.customDetails.ticket.queue` creates `ticket` if the event has none. Write a dot inside a key as `\.`, as in `context.event.customDetails.k8s\.namespace`, and an array position as `[0]`. A path can otherwise contain only the letters A to Z, digits, `_` and `-`, so a key with a space, a colon, a slash or any other character cannot be written.

## Reference event fields

A value can contain references to the event in double braces, such as `{{context.event.summary}}` or `{{context.event.customDetails.env}}`. Every operation renders them. That covers the text of **Set value**, the target values and default of **Map values**, the values of **Merge properties** and every field of an **Add to array** item. References use the [ilert template language](https://docs.ilert.com/developer-docs/itl-ilert-template-language.md), so functions work too: `{{context.event.customDetails.env.upperCase()}}`.

Two fields read differently from how they are written:

* **The alert key reads as `incidentKey`.** As a target, `context.event.alertKey` works. As a **Source field**, in a reference or in a condition, write `context.event.incidentKey`: `{{context.event.alertKey}}` renders `undefined`, and a condition on `context.event.alertKey` matches nothing. **Source field** and the condition editor offer `alertKey` all the same. In the logs, the field is called `incidentKey`.
* **A field the event does not have renders as the word `undefined`.** A template like `[{{context.event.customDetails.env}}] {{context.event.summary}}` turns into `[undefined] Refund queue backlog` for an event without `env`. Give the reference a fallback with `orElse`: `{{context.event.customDetails.env.orElse("no env")}}`.

## Limit the node to some events

The condition is built the same way as a **Branch** condition: filter groups combined with AND and OR, or [ICL](https://docs.ilert.com/developer-docs/icl-ilert-condition-language.md) in the code editor. Events that do not match pass through unchanged.

ICL compares text without regard to case, so `context.event.priority == 'high'` matches `HIGH`. In event flows, `!= nil` cannot tell you whether a field exists, because it is also true for a field the event does not have. Test for the value you expect instead, such as `context.event.customDetails.env == 'prod'`.

## Operations

### Set value

Writes a fixed value into the target. The editor adapts to the field:

* **Event type**, **priority** and **severity**: pick a value from the list.
* **Text**: type it, with references if you like.
* **Labels** and **custom details**: a **Properties** table of keys and values. It replaces all labels or all custom details. To add without removing, use **Merge properties**.
* **Lists**: an **Items** list that replaces the entire list. With no items, the list is cleared. If every item turns out invalid once its references are filled in, the list is left as it was.
* **A path the editor does not know**, such as a custom details path: the value is text by default. **Use as object** and **Use as array** switch the editor.

### Copy from field

Copies the value of **Source field** into the target. If the event has no such field, the target keeps its value. Into a custom details path, any value is copied, objects and lists included. Into one of the event's own fields, only text, numbers and true or false are copied, as text; an object or a list leaves the target unchanged.

### Template

Composes text from fixed text and references, using the [ilert template language](https://docs.ilert.com/developer-docs/itl-ilert-template-language.md):

```
[{{context.event.customDetails.env.orElse("no env")}}] {{context.event.summary}}
```

### Map values

Looks up the value of **Source field** in a table and writes the matching **Target value**. Matching is exact and case-sensitive: `Critical` does not match a row for `critical`. When no row matches, the rule writes **Default value (when no mapping matches)**.

{% hint style="warning" %}
**Always fill in Default value (when no mapping matches), and every Target value.** If you leave the default empty, an event that matches no row loses the target field: its summary, details, priority, severity, alert key or routing key is cleared, and a custom details path is set to `null`. The hint below the field says the opposite, but clearing is what happens. A row with an empty **Target value** clears the field the same way. To keep a text field as it was, use a reference to the field itself, such as `{{context.event.summary}}`.
{% endhint %}

### Merge properties

Adds keys to `context.event.labels` or to custom details. A key the event already has keeps its value: an event that arrives with the label `team: web` keeps `web` even if the rule sets `team` to `payments`. Within custom details, nested objects are merged level by level, under the same rule.

To overwrite labels, use **Set value**, which replaces all of them.

### Add to array

Appends items to a list, creating the list if the event has none. Each kind of list has its own fields:

| List                     | Fields                                                                                                                                               |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `context.event.links`    | **URL** and **Link text**, both required. The URL must start with `http://` or `https://`, and is limited to 2,048 characters; the text to 512       |
| `context.event.images`   | **Image URL**, **Link URL (optional)**, **Alt text**                                                                                                 |
| `context.event.services` | **ID** or **Service alias**. A service with the same alias as one the event already lists, or the same ID when there is no alias, is not added again |
| `context.event.comments` | **Creator** and **Comment**. **Comment** is required                                                                                                 |

Items can contain references. An item that is invalid once its references are filled in, such as a link whose URL renders as `undefined`, is skipped and logged as an error. The other items are still added.

## Check what a node changed

Open the flow, click **View event flow logs**, and select an entry to open **Event flow log details**. The **Transform event** entry shows:

* **Transformed fields**: each field the node changed, as before → after. Lists and objects show their type and size, such as `ARRAY (0)` → `ARRAY (1)`, and custom details show only whether they changed.
* **Transformed event**: the whole event as it left the node.
* **Skipped**, instead, when the node's condition did not match.
* **Error in** and the rule's name, with the reason, once for each problem. A rule that skips three items logs three errors.

If no rule changed anything, the entry has neither **Transformed fields** nor **Transformed event**.

The **Incoming event** entry above it can show the event as it left the Transform event node rather than as it arrived. The values the event arrived with are the "before" values under **Transformed fields**.

<figure><img src="https://3394882078-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M76ygPnS4HUcFSX8ulm%2Fuploads%2Fgit-blob-edecd99d25670f856feca44a7966a599c4c56d3f%2Fevent-flow-transform-log.png?alt=media" alt="Event flow log details for one event in the Acme Checkout normalization flow. The Transform event entry lists Transformed fields: summary from Checkout p95 latency above 2s to [prod] Checkout p95 latency above 2s, priority to HIGH, links from ARRAY (0) to ARRAY (1), and labels from NULL (undefined) to OBJECT (1). Above it, the Incoming event entry already shows the rewritten summary and HIGH priority."><figcaption><p>Read <strong>Transformed fields</strong> for what a node did. The <strong>Incoming event</strong> entry above already shows the rewritten summary.</p></figcaption></figure>

## Example: normalize events from a monitoring tool

A tool sends its severity as a word in a custom field, puts the environment in another, and links its runbook in a third:

```bash
curl -X POST https://api.ilert.com/api/events \
  -H 'Content-Type: application/json' \
  -d '{
    "integrationKey": "YOUR_INTEGRATION_KEY",
    "eventType": "ALERT",
    "summary": "Checkout p95 latency above 2s",
    "alertKey": "checkout-latency",
    "customDetails": {
      "severity": "critical",
      "env": "prod",
      "runbook": "https://runbooks.acme.example/checkout-latency"
    }
  }'
```

`YOUR_INTEGRATION_KEY` is the key of the API integration on the flow's **Incoming event** node. One Transform event node with four rules makes the event ready to route:

| Rule                   | Target field             | Operation            | Value                                                                                                                                                                |
| ---------------------- | ------------------------ | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Priority from severity | `context.event.priority` | **Map values**       | **Source field** `context.event.customDetails.severity`; `critical` → `HIGH`, `error` → `HIGH`, `warning` → `LOW`; **Default value (when no mapping matches)** `LOW` |
| Environment in summary | `context.event.summary`  | **Template**         | `[{{context.event.customDetails.env.orElse("no env")}}] {{context.event.summary}}`                                                                                   |
| Team label             | `context.event.labels`   | **Merge properties** | `team` → `payments`                                                                                                                                                  |
| Runbook link           | `context.event.links`    | **Add to array**     | **URL** `{{context.event.customDetails.runbook}}`, **Link text** `Runbook`                                                                                           |

The event leaves the node with these changes, and the custom details are unchanged:

| Field    | Before                          | After                                                                   |
| -------- | ------------------------------- | ----------------------------------------------------------------------- |
| Summary  | `Checkout p95 latency above 2s` | `[prod] Checkout p95 latency above 2s`                                  |
| Priority | none                            | `HIGH`                                                                  |
| Labels   | none                            | `team: payments`                                                        |
| Links    | none                            | `Runbook`, pointing at `https://runbooks.acme.example/checkout-latency` |

## Limits

| Limit                                                      | Value                                                                      |
| ---------------------------------------------------------- | -------------------------------------------------------------------------- |
| Rules per node                                             | 30. The editor lets you add more, but ilert rejects the node when you save |
| Characters in a value, template or condition               | 4,096                                                                      |
| Items per **Add to array** rule                            | 50                                                                         |
| Rows per **Map values** table                              | 200                                                                        |
| Properties per **Set value** or **Merge properties** table | 299, counting nested values (300 for **Merge properties** on labels)       |
| Items a **Set value** list writes                          | 50. Any further items are dropped when the rule runs                       |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ilert.com/alerting/configure-alerting/event-flows/transform-event.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
