Variable Replacement
The variable replacement mapping is an essential technique used to combine the values of multiple fields into a single field through the use of variables within a template or pattern. This is particularly useful in contexts where composite messages or strings need to be constructed dynamically from various data points in a message. Here's a detailed breakdown of how to set up a variable replacement mapping:
Attributes Required for Variable Replacement Mapping
| Attribute | Required (Y/N) | Description |
|---|---|---|
| from | Y | Specifies the source field name, whose value is to be replaced. |
| to | Y | Designates the target field name, where the replaced value will be stored. |
| precedence | N | Determines the order in which this mapping is applied relative to others. |
| Function type | Y | Should be set to "String functions" to enable text manipulation capabilities. |
| Function | Y | Must be set to "variable replacement", indicating the use of variable data for replacement. |
| Replacement string | Y | Contains the template with variables that will be substituted with actual field values. |
Example Configuration:
Scenario:
In this example, we want to consolidate various fields into a single message field named "slack", which is intended to format a notification message that includes details such as a user's name, event time, and a brief description.
Configuration:
- from: incident/description
- to: slack
- Function type: String functions
- Function: Variable replacement
- Replacement string: State[incident/status] Description [incident/description] TicketID:[incident/id]
Each variable in the replacement string (e.g., [user], [time], [description]) corresponds to a field in the message, and the content of these fields is dynamically inserted into the pattern specified in the "Replacement string".