Regular expression
The regular expression (regex) mapping serves as a dynamic replacement tool, similar to a lookup table, but leverages the flexibility of regular expressions to define complex matching and replacement rules. The attributes that need to be set in a regex mapping are:
Configuration Attributes for Regex Mapping
| Attribute | Required (Y/N) | Description |
|---|---|---|
| from | Y | Specifies the field name from which data is mapped. |
| to | Y | Specifies the field name to which data is mapped. |
| precedence | N | Determines the order in which mappings are applied. |
| Function type | Y | Must be set to "String functions" to use regex capabilities. |
| function | Y | Set to "regular expression" to enable regex-based mapping. |
| Regex | Y | Defines the regular expression used for matching patterns within the field. Mode modifiers: Optional modifiers that adjust the behavior of the regex, such as (?s) to make the dot match newline characters. |
| Replacement string | N | Defines the replacement string or format based on capture groups; defaults to the first capture group if unspecified. |
Advanced Options
- Value Map: A regex mapping can include a nested value map, utilizing the capture groups ($n$) defined in the Regex attribute for detailed replacements in the "Replacement string".
- Capture Groups in
toandfromFields: If capture groups are used in thefromandtofields, the "Replacement string" can be adjusted to reference these using$n#to avoid confusion with capture groups from the regex pattern itself.
Example Application
Consider the scenario where the Zabbix API outputs a field with value vfs.fs.size[/,free] that you need to parse for monitoring disk space. Using regex mapping, this value can be split into two different fields:
/metric/type: Extracted to represent the metric type, such as "disk_free"./ci/element: Used to capture specific filesystem elements, such as "/".