3 Preprocessing examples

Overview

This section presents examples of using preprocessing steps to accomplish some practical tasks.

Filtering VMware event log records

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 vmware.eventlog item 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 item.

3. In the Preprocessing tab of the dependent item, click Add to create a preprocessing step and select Matches regular expression from the drop-down. Then, specify one of the following patterns:

  • For filtering all log events:
.* logged in .*
  • For filtering lines containing usernames after "User":
\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. Please note that discarded values are not stored in the database; as a result, triggers are not evaluated and trend data is not generated.

Alternatively, you may use the Regular expression preprocessing step to extract matching groups and control output:

  • For extracting and outputting the entire log event containing "logged in", specify the following parameters:
Pattern: .*logged in.*
       Output: \0
  • For extracting and outputting usernames following "User":
Pattern: User (.*?)(?=\ )
       Output: \1

Checking retrieved value type

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 specify the following parameter (multiplies the retrieved value by 1):

1

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. Please note that discarded values are not stored in the database; as a result, triggers are not evaluated and trend data is not generated.

Checking for not supported value

This example uses the Check for not supported value preprocessing step to check if the item value could not be retrieved.

When a Zabbix server/proxy poller process attempts to collect an item value, it may:

  • Return a valid result.
  • Return a result that initially seems valid but may become unsupported later (e.g., due to a value type mismatch after preprocessing).
  • Return an error of collecting the value, causing the item to become unsupported. Common causes include:
    • Unknown item key (for Zabbix agent, Simple check, or Zabbix internal items)
    • Unknown OID (SNMP agent), unknown sensor (IPMI agent), or no JMX metric (JMX agent)
    • Cannot read trap file (SNMP trap)
    • Script not found (External check)
    • No such URL (HTTP agent, Browser)
    • Login failed (SSH agent, TELNET agent)
    • Invalid formula syntax (Calculated), JavaScript syntax error (Script), or invalid SQL (Database monitor)

To detect and handle errors of collecting item values, you can use the Check for not supported value preprocessing step. Note that this step is always executed first and only detects errors that occur before preprocessing begins.

In the Preprocessing tab of an item, select the Check for not supported value preprocessing step and specify one of the following parameters:

  • For any errors:
Parameter: any error
  • For errors containing "cannot connect":
Parameter: error matches
       Pattern: (?i)cannot connect

Then, use the Custom on fail option to discard the value (in this case, the error), set a custom value, or return a custom error message. Please note that discarded values are not stored in the database; as a result, triggers are not evaluated and trend data is not generated.