Skip to main content

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

AttributeRequired (Y/N)Description
fromYSpecifies the source field name, whose value is to be replaced.
toYDesignates the target field name, where the replaced value will be stored.
precedenceNDetermines the order in which this mapping is applied relative to others.
Function typeYShould be set to "String functions" to enable text manipulation capabilities.
FunctionYMust be set to "variable replacement", indicating the use of variable data for replacement.
Replacement stringYContains 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".

Result:

slack "State: new Description: This is an incident TicketID: 32554"