This section presents examples of using preprocessing steps to accomplish some practical tasks.
This example uses the Matches regular expression preprocessing step to filter unnecessary events from the VMware event log.
1. On a working VMware Hypervisor host, check that the event log item vmware.eventlog is present and working properly. Note that the event log item could already be present on the hypervisor if a VMware template has been linked during the host creation.
2. On the VMware Hypervisor host, create a dependent item of "Log" type and set the event log item as its master.
3. In the Preprocessing tab of the dependent item, select the "Matches regular expression" preprocessing step and specify, for example, one of the following parameters:
# Filters all log events:
pattern: .* logged in .*
# Filters lines containing usernames after "User":
pattern: \bUser\s+\K\S+
If the regular expression is not matched, then the dependent item becomes unsupported with a corresponding error message. To avoid this, mark the "Custom on fail" checkbox and select an option such as discarding the value or setting a custom one.
Alternatively, you may use the Regular expression preprocessing step to extract matching groups and control output. For example:
# Extracts and outputs the entire log event containing "logged in":
pattern: .*logged in.*
output: \0
# Extracts and outputs usernames following "User":
pattern: User (.*?)(?=\ )
output: \1
This example uses the Custom multiplier preprocessing step to check if the retrieved item value type is numeric.
In the Preprocessing tab of an item, select the "Custom multiplier" preprocessing step and set the following parameter:
If preprocessing fails (e.g., input is not numeric), then the item becomes unsupported with a corresponding error message. To avoid this, mark the "Custom on fail" checkbox and select an option such as discarding the value or setting a custom one.