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.
| Option | Use | Default and range |
|---|---|---|
name | Service: slack, pagerduty, virustotal, shuffle, maltiverse or a name starting with custom- | No single default |
hook_url | URL for communicating with the service; required for Slack, Shuffle and Maltiverse | n/a |
api_key | API key; required for PagerDuty, VirusTotal and Maltiverse | n/a |
alert_format | Alert format; json required for Slack, VirusTotal, Shuffle and Maltiverse, and for PagerDuty since Wazuh 4.7.0 | No default; allowed json |
level | Minimum rule level of the alert | Optional; 0 to 16; without the filter all alerts are sent |
rule_id | Comma-separated list of rule IDs | Optional; without the filter all IDs match |
group | A group name or comma-separated groups | Optional; without the filter all groups match |
event_location | Filter by event source using an sregex expression | Optional |
max_log | Maximum length of the alert excerpt when the format is not json | Default 165; 165 to 1024; longer strings are truncated and end with ... |
options | JSON object with fields that customize the integration payload; overrides earlier fields | Optional |
timeout | Time to wait for a valid response from the integration server, in seconds | Default 10; positive integer |
retries | Maximum number of attempts after a timeout | Default 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.
| Integration | Required options named in the documentation | Notes |
|---|---|---|
slack | hook_url, alert_format equal to json | Requires a Slack incoming webhook; options can contain Slack message fields |
pagerduty | api_key; since Wazuh 4.7.0 also alert_format | Uses an Events API v2 integration key; can be filtered by level |
virustotal | api_key, alert_format equal to json, group equal to syscheck | Rules from the syscheck group are available |
shuffle | hook_url, alert_format equal to json | Requires a working webhook trigger in the Shuffle workflow |
maltiverse | hook_url, api_key, alert_format equal to json | Enriches 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.
| Argument | Value passed |
|---|---|
$1 | Path to the temporary alert file in JSON |
$2 | The api_key value or an empty argument |
$3 | The 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 option | Meaning | Default and range |
|---|---|---|
email_notification | Enables or disables email notifications | no; yes or no |
smtp_server | SMTP server or the full path to a sendmail-compatible program | No default value |
email_from | Sender address of the message | No default value; a valid email address |
email_to | Default recipient; repeat the option for more recipients | No default value; a valid email address |
email_maxperhour | Maximum number of email alerts per hour | 12; 1 to 1000000 |
email_log_source | Alert file read by the email module | alerts.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.
| Option | Meaning and values |
|---|---|
email_to | Required single email address; repeat the element for the next recipient |
level | Minimum alert level from 0 to 16; should be equal to or higher than email_alert_level in the alerts block |
group | Rule groups; separate multiple groups with a vertical bar, and a trailing comma prevents partial matches |
event_location | Agent name, hostname, IP address or log file; if repeated, only the last value is used |
format | Default full; default and full send a plain message, sms uses a compact format |
rule_id | One or more rule IDs separated by a comma and a space |
do_not_delay | Empty XML element; sends the message immediately instead of waiting for grouping |
do_not_group | Empty 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>
Rule options related to email
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:
| Value | Effect according to the documentation |
|---|---|
alert_by_email | An alert from this rule is always sent by email |
no_email_alert | An alert from this rule is never sent by email |
no_log | The alert is not recorded |
no_full_log | The 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
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/integration.html
- https://documentation.wazuh.com/current/user-manual/manager/integration-with-external-apis.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/global.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/email-alerts.html