Esta es una traducción de la página de documentación original en español. Ayúdanos a mejorarla.

3 Ejemplos de preprocesamiento

Descripción general

Esta sección presenta ejemplos del uso de pasos de preprocesamiento para realizar algunas tareas prácticas.

Filtrado de registros de eventos de VMware

Usar expresiones regulares para filtrar eventos innecesarios de el registro de eventos de VMware.

1. En un host VMware Hypervisor en funcionamiento, verifique que el elemento del registro de eventos vmware.eventlog[<url>,<modo>,<severidad>] está presente y funciona correctamente. Nota que el elemento del registro de eventos ya podría estar presente en el hipervisor si la plantilla Template VM VMware se ha vinculado durante el host creación.

2. En el host de VMware Hypervisor, cree un dependiente item de tipo 'Registro' y establezca el elemento del registro de eventos como su maestro.

En la pestaña "Preprocesamiento" del elemento dependiente, seleccione "Coincidencias opción de validación de expresión regular" y patrón de relleno, por ejemplo:

".* iniciado sesión .*": filtra todos los eventos de registro en el registro de eventos
       "\bUser\s+\K\S+" - filtra solo líneas con nombres de usuario del registro de eventos

::: nota importante Si la expresión regular no coincide, entonces el el elemento dependiente deja de ser compatible con el mensaje de error correspondiente. Para evitar esto, marque la casilla de verificación "Personalizado en caso de error" y seleccione descartar valor inigualable, por ejemplo. :::

Otro enfoque que permite utilizar grupos coincidentes y control de salida es seleccionar la opción "Expresión regular" en la pestaña "Preprocesamiento" y llenar parámetros, por ejemplo:

patrón: ".*logged in.*", salida: "\0" - filtra todos los eventos de registro en el registro de eventos
       patrón "Usuario (.*?)(?=\ )", salida: "\1" - filtra solo los nombres de usuario del registro de eventos

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 set the following parameter:

# Multiplies the retrieved value by 1:
       number: 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.

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.