Preprocessing allows you to apply transformations to the received item values before saving them to the database. These transformations/preprocessing steps are performed by Zabbix server or proxy (if items are monitored by proxy).
This feature supports a variety of use cases, such as:
One or more preprocessing steps can be configured for an item. These steps are executed in the order they are configured.
If a preprocessing step fails, an item becomes unsupported. This can be avoided by Custom on fail error-handling (available for most transformations), allowing you to discard values or set custom values.
For log items, log metadata (without value) will always reset the item unsupported state, making it supported again. This happens even if the initial error occurred after receiving a log value from agent.
All values passed to preprocessing are initially treated as strings. Conversion to the desired value type (as defined in item configuration) is performed at the end of the preprocessing pipeline. However, specific preprocessing steps may trigger earlier conversions, if required. For detailed technical information, see Preprocessing details.
To ensure that your preprocessing configuration works as expected, you can test it.
See also: Preprocessing examples
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 no item value could be retrieved. | |
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.