PL EN
WB-394FD287TLP:CLEARWazuh 4

Wazuh Integrator and email: alerts outside the manager

Configuring wazuh-integratord and email in Wazuh: level, rule_id and group filters, custom- scripts, the email_maxperhour limit and email_alerts blocks.

Wazuh can pass selected alerts to external services through the Integrator module or send them by email. Selecting by level, rule, group and event source narrows the stream to the alerts that should reach the recipient.

Integrator on the manager

The wazuh-integratord module connects Wazuh alerts to external APIs and notification tools. The configuration goes into the <integration> block inside <ossec_config> in /var/ossec/etc/ossec.conf on the manager. After a configuration change, the documentation requires a manager restart.

<ossec_config>
  <integration>
    <name>slack</name>
    <hook_url>https://hooks.example.com/alerts</hook_url>
    <alert_format>json</alert_format>
    <level>10</level>
  </integration>
</ossec_config>

The example shows a fictitious URL and a limit by alert level. The Slack integration requires hook_url and alert_format set to json.

Integration block options

In the table, n/a means the reference page gives no default value. Required options depend on the chosen integration.

OptionUseDefault and range
nameService: slack, pagerduty, virustotal, shuffle, maltiverse or a name starting with custom-No single default
hook_urlURL for communicating with the service; required for Slack, Shuffle and Maltiversen/a
api_keyAPI key; required for PagerDuty, VirusTotal and Maltiversen/a
alert_formatAlert format; json required for Slack, VirusTotal, Shuffle and Maltiverse, and for PagerDuty since Wazuh 4.7.0No default; allowed json
levelMinimum rule level of the alertOptional; 0 to 16; without the filter all alerts are sent
rule_idComma-separated list of rule IDsOptional; without the filter all IDs match
groupA group name or comma-separated groupsOptional; without the filter all groups match
event_locationFilter by event source using an sregex expressionOptional
max_logMaximum length of the alert excerpt when the format is not jsonDefault 165; 165 to 1024; longer strings are truncated and end with ...
optionsJSON object with fields that customize the integration payload; overrides earlier fieldsOptional
timeoutTime to wait for a valid response from the integration server, in secondsDefault 10; positive integer
retriesMaximum number of attempts after a timeoutDefault 3; positive integer

max_log applies to the alert excerpt and is not a length limit for an alert sent in JSON format. timeout and retries apply to waiting for the integration server.

Filters limit the number of notifications

If no filters are configured, the integrator sends all alerts. level sets the minimum level. rule_id limits forwarding to the listed IDs, and group to the given groups. Values within a list work as alternatives: matching one ID or one group from the list is enough.

When rule_id and group are set together, the alert must meet both conditions.

event_location filters events by origin using an sregex expression.

Built-in integrations

Available integration names and required fields depend on the service.

IntegrationRequired options named in the documentationNotes
slackhook_url, alert_format equal to jsonRequires a Slack incoming webhook; options can contain Slack message fields
pagerdutyapi_key; since Wazuh 4.7.0 also alert_formatUses an Events API v2 integration key; can be filtered by level
virustotalapi_key, alert_format equal to json, group equal to syscheckRules from the syscheck group are available
shufflehook_url, alert_format equal to jsonRequires a working webhook trigger in the Shuffle workflow
maltiversehook_url, api_key, alert_format equal to jsonEnriches alerts with Maltiverse data; the documentation points to the maltiverse rule group for results

Configuration of a custom service, the key is a placeholder:

<integration>
  <name>custom-example</name>
  <hook_url>https://hooks.example.com/alerts</hook_url>
  <api_key>API_KEY</api_key>
  <alert_format>json</alert_format>
  <level>10</level>
  <group>example-auth,example-network</group>
</integration>

Integration with a custom script

The name of a custom integration must start with custom-. The script goes into /var/ossec/integrations/, and its name must match the <name> value. The documentation requires permissions 750, owner root:wazuh and a shebang line pointing to the interpreter.

The module passes the script three arguments. $1 is the absolute path to a temporary file with the alert in JSON. $2 holds the api_key value from the configuration, and $3 the hook_url value. If the matching option is not set, the argument is empty. A full example of a custom integration whose result comes back to Wazuh as a secondary alert is in the post on external alert analysis.

ArgumentValue passed
$1Path to the temporary alert file in JSON
$2The api_key value or an empty argument
$3The hook_url value or an empty argument

The documentation lists example fields available in the alert: rule level, ID, rule description, agent ID and name, and the syscheck path. It recommends checking /var/ossec/logs/alerts/alerts.json to learn the format used for interpretation.

Script permissions and owner:

chmod 750 /var/ossec/integrations/custom-example
chown root:wazuh /var/ossec/integrations/custom-example

A change in ossec.conf takes effect after a manager restart. The documentation gives the command for systemd and for SysV init:

systemctl restart wazuh-manager
service wazuh-manager restart

Global email configuration

Email uses settings in the <global> block. email_notification defaults to no. The default recipient can be repeated for more addresses.

Global optionMeaningDefault and range
email_notificationEnables or disables email notificationsno; yes or no
smtp_serverSMTP server or the full path to a sendmail-compatible programNo default value
email_fromSender address of the messageNo default value; a valid email address
email_toDefault recipient; repeat the option for more recipientsNo default value; a valid email address
email_maxperhourMaximum number of email alerts per hour12; 1 to 1000000
email_log_sourceAlert file read by the email modulealerts.json; alerts.log or alerts.json; the ossec.conf installed with the manager sets alerts.log

Messages above the email_maxperhour limit are queued and sent together as one message at the end of the hour. This happens regardless of whether email grouping is enabled. The limit caps the sending rate but does not choose alert types. Granular configuration does the selecting.

<global>
  <email_notification>yes</email_notification>
  <smtp_server>smtp.example.com</smtp_server>
  <email_from>[email protected]</email_from>
  <email_to>[email protected]</email_to>
  <email_maxperhour>12</email_maxperhour>
  <email_log_source>alerts.json</email_log_source>
</global>

Choosing alerts in email_alerts

Granular <email_alerts> blocks extend the global configuration. Global email configuration is required to use these options. Each block requires email_to. For multiple recipients, repeat the element instead of giving a list of addresses.

OptionMeaning and values
email_toRequired single email address; repeat the element for the next recipient
levelMinimum alert level from 0 to 16; should be equal to or higher than email_alert_level in the alerts block
groupRule groups; separate multiple groups with a vertical bar, and a trailing comma prevents partial matches
event_locationAgent name, hostname, IP address or log file; if repeated, only the last value is used
formatDefault full; default and full send a plain message, sms uses a compact format
rule_idOne or more rule IDs separated by a comma and a space
do_not_delayEmpty XML element; sends the message immediately instead of waiting for grouping
do_not_groupEmpty XML element; disables combining multiple alerts into one message

The example sends alerts from level 10 in the example-auth group to the given recipient. do_not_delay is a standalone empty element.

<email_alerts>
  <email_to>[email protected]</email_to>
  <level>10</level>
  <group>example-auth,</group>
  <do_not_delay/>
</email_alerts>

Besides configuration in ossec.conf, the rule syntax documentation describes the <options> element. Two of its values concern email, and two more change how the alert is recorded:

ValueEffect according to the documentation
alert_by_emailAn alert from this rule is always sent by email
no_email_alertAn alert from this rule is never sent by email
no_logThe alert is not recorded
no_full_logThe alert does not contain the full_log field

Each option is written in a separate <options> element. The example combines disabling email with omitting the full_log field:

<rule id="100010" level="8">
  <match>illegal user|invalid user</match>
  <description>sshd: Attempt to login using a non-existent user</description>
  <options>no_email_alert</options>
  <options>no_full_log</options>
</rule>

What the documentation does not specify

The documentation gives no backoff strategy or jitter for integrator retries, no webhook delivery guarantees, no service throughput limits and no maximum queue size. It also does not describe the full JSON schema passed to the script, the behavior when email and an integration match at the same time, or how alert_by_email and no_email_alert interact with email_maxperhour and the email_alerts blocks. For combined integrator filters it describes alternatives within lists and an AND condition between rule_id and group, but it does not specify the full logic for combining all the other filters.

Sources

↑↓ select Enter open Esc close