In preprocessing it is possible to apply transformations to the received item values before saving them to the database.
There are many uses for this functionality. You may want to, for example:
One or several transformations are possible. Transformations (preprocessing steps) are executed in the order in which they are defined.
An item will become unsupported if any of the preprocessing steps fail. This can be avoided by Custom on fail error-handling (available for supported transformations), which can be configured to discard the value or set a specified value.
To make sure that the configured preprocessing pipeline works, it is possible to test it.
For log items, log metadata (without value) will always reset the item unsupported state and make the item supported again, even if the initial error occurred after receiving a log value from agent.
Preprocessing is done by Zabbix server or proxy (if items are monitored by proxy).
Note that all values passed to preprocessing are of the string type; conversion to the desired value type (as defined in item configuration) is performed at the end of the preprocessing pipeline. Conversions, however, may also take place if required by the corresponding preprocessing step. See preprocessing details for more technical information.
See also: Regular expression preprocessing example
Preprocessing steps are defined in the Preprocessing tab of the item configuration form.
Click on Add to select a supported transformation.
The Type of information field is displayed at the bottom of the tab when at least one preprocessing step is defined. If required, it is possible to change the type of information without leaving the Preprocessing tab. See Creating an item for the detailed parameter description.
All supported transformations are listed below. Click on the transformation name to see full details about it.
Name | Description | Type |
---|---|---|
Regular expression | Match the value to the regular expression and replace with the required output. | Text |
Replace | Find the search string and replace it with another (or nothing). | |
Trim | Remove specified characters from the beginning and end of the value. | |
Right trim | Remove specified characters from the end of the value. | |
Left trim | Remove specified characters from the beginning of the value. | |
XML XPath | Extract value or fragment from XML data using XPath functionality. | Structured data |
JSON Path | Extract value or fragment from JSON data using JSONPath functionality. | |
CSV to JSON | Convert CSV file data into JSON format. | |
XML to JSON | Convert data in XML format to JSON. | |
SNMP walk value | Extract value by the specified OID/MIB name and apply formatting options. | SNMP |
SNMP walk to JSON | Convert SNMP values to JSON. | |
SNMP get value | Apply formatting options to the SNMP get value. | |
Custom multiplier | Multiply the value by the specified integer or floating-point value. | Arithmetic |
Simple change | Calculate the difference between the current and previous value. | Change |
Change per second | Calculate the value change (difference between the current and previous value) speed per second. | |
Boolean to decimal | Convert the value from boolean format to decimal. | Numeral systems |
Octal to decimal | Convert the value from octal format to decimal. | |
Hexadecimal to decimal | Convert the value from hexadecimal format to decimal. | |
JavaScript | Enter JavaScript code. | Custom scripts |
In range | Define a range that a value should be in. | Validation |
Matches regular expression | Specify a regular expression that a value must match. | |
Does not match regular expression | Specify a regular expression that a value must not match. | |
Check for error in JSON | Check for an application-level error message located at JSONPath. | |
Check for error in XML | Check for an application-level error message located at XPath. | |
Check for error using a regular expression | Check for an application-level error message using a regular expression. | |
Check for not supported value | Check if there was an error in retrieving item value. | |
Discard unchanged | Discard a value if it has not changed. | Throttling |
Discard unchanged with heartbeat | Discard a value if it has not changed within the defined time period. | |
Prometheus pattern | Use the following query to extract the required data from Prometheus metrics. | Prometheus |
Prometheus to JSON | Convert the required Prometheus metrics to JSON. |
Note that for Change and Throttling preprocessing steps, Zabbix has to remember the last value to calculate/compare the new value as required. These previous values are handled by the preprocessing manager. If Zabbix server or proxy is restarted or there is any change made to preprocessing steps, the last value of the corresponding item is reset, resulting in:
Match the value to the regular expression and replace with the required output.
Parameters:
Comments:
Find the search string and replace it with another (or nothing).
Parameters:
Comments:
Remove specified characters from the beginning and end of the value.
Remove specified characters from the end of the value.
Remove specified characters from the beginning of the value.
Extract value or fragment from XML data using XPath functionality.
Comments:
Examples:
number(/document/item/value) #will extract '10' from <document><item><value>10</value></item></document>
number(/document/item/@attribute) #will extract '10' from <document><item attribute="10"></item></document>
/document/item #will extract '<item><value>10</value></item>' from <document><item><value>10</value></item></document>
Extract value or fragment from JSON data using JSONPath functionality.
If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Convert CSV file data into JSON format.
For more information, see: CSV to JSON preprocessing.
Convert data in XML format to JSON.
For more information, see: Serialization rules.
If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Extract value by the specified OID/MIB name and apply formatting options:
' '
are replaced by ':'
);If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Convert SNMP values to JSON.
Specify a field name in the JSON and the corresponding SNMP OID path. Field values will be populated by values in the specified SNMP OID path.
Comments:
Apply formatting options to the SNMP get value:
' '
are replaced by ':'
);If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Multiply the value by the specified integer or floating-point value.
Comments:
1e+70
; user macros and LLD macros; strings that include macros, for example, {#MACRO}e+10
, {$MACRO1}e+{$MACRO2}
. The macros must resolve to an integer or a floating-point number.Calculate the difference between the current and previous value.
Comments:
Calculate the value change (difference between the current and previous value) speed per second.
Comments:
Convert the value from boolean format to decimal.
Comments:
Convert the value from octal format to decimal.
If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Convert the value from hexadecimal format to decimal.
If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Enter JavaScript code in the modal editor that opens when clicking in the parameter field or on the pencil icon next to it.
Comments:
Define a range that a value should be in by specifying minimum/maximum values (inclusive).
Comments:
Specify a regular expression that a value must match.
If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Specify a regular expression that a value must not match.
If you mark the Custom on fail checkbox, it is possible to specify custom error-handling options: either to discard the value, set a specified value, or set a specified error message. In case of a failed preprocessing step, the item will not become unsupported if the option to discard the value or set a specified value is selected.
Check for an application-level error message located at JSONPath. Stop processing if succeeded and the message is not empty; otherwise, continue processing with the value that was before this preprocessing step.
Comments:
Check for an application-level error message located at XPath. Stop processing if succeeded and the message is not empty; otherwise, continue processing with the value that was before this preprocessing step.
Comments:
Check for an application-level error message using a regular expression. Stop processing if succeeded and the message is not empty; otherwise, continue processing with the value that was before this preprocessing step.
Parameters:
Comments:
Check if no item value could be retrieved. Specify how the failure should be processed, based on inspecting the returned error message.
Parameters:
Comments:
Discard a value if it has not changed.
Comments:
Discard a value if it has not changed within the defined time period (in seconds).
Comments:
Use the following query to extract the required data from Prometheus metrics.
See Prometheus checks for more details.
Convert the required Prometheus metrics to JSON.
See Prometheus checks for more details.
User macros and user macros with context are supported in:
The macro context is ignored when a macro is replaced with its value. The macro value is inserted in the code as is, it is not possible to add additional escaping before placing the value in the JavaScript code. Please be advised that this can cause JavaScript errors in some cases.