The copy function mapping defines a simple conversion of the field. It has a “from” field and a “to” field that define a field name translation, leaving the value unchanged. The mapping types are defined with “function type” and "function" attributes in the mapping. The default string function is "Copy".
The translations between the Test Message field and the Test result field are highlighted in red.
All mappings can have regular expressions in the from field. This regular expression needs to include a capture group that can be referenced in the to field.
This is used in messages that have an arrays in them.
To select a field from all elements of the array, we use the following expression in the from field. Notice the capture group in the regular expression.
To reference the capture group, we use the format $n$, where n is the number of the capture group. Content of the to field:
event/metrics/$1$/description
CODE
Whenever a regular expression is used in the "from" field, the context of any filters defined in the mapping changes. Normally the filter is applied to the entire message, but when a regular expression is used, the context of the filter is limited to the message content after the last / (slash) in that field. For example, if the message contains this:
mydata/0/interesting = true
mydata/0/name = One flew over the cuckoo's nest
mydata/1/interesting = true
mydata/1/name = The Chosen
mydata/2/interesting = false
mydata/2/name = The art of the deal
CODE
and a filter is defined as
on a mapping that copies
mydata/(.*) to /mybooks/$1$
CODE
the result will be
mybooks/0/interesting = true
mybooks/0/name = One flew over the cuckoo's nest
mybooks/1/interesting = true
mybooks/1/name = The Chosen
CODE