Archives vs alerts in Wazuh: what goes where
archives.log, archives.json and alerts.json: the logall, logall_json and log_alert_level options, Filebeat archives, wazuh-archives-* and file rotation.
Alerts hold the events that passed through the rules and the level threshold, and archives hold all events received by the server. Options in ossec.conf and the Filebeat configuration decide which files and indices are created.
The description applies to Wazuh 4.14. The examples are synthetic.
Event streams
| Stream | Contents | Option in global or alerts | File or index |
|---|---|---|---|
archives.log | All events in syslog format, including those with no rule match | logall | /var/ossec/logs/archives/archives.log |
archives.json | The same events in JSON | logall_json | /var/ossec/logs/archives/archives.json, wazuh-archives-* indices |
alerts.log | Alerts in text format | alerts_log | /var/ossec/logs/alerts/alerts.log |
alerts.json | The same alerts in JSON | jsonout_output | /var/ossec/logs/alerts/alerts.json, wazuh-alerts-* indices |
The server writes all the events it receives, whether or not they triggered a rule, but only when archives are enabled. By default archives.log and archives.json are disabled, because the data is stored indefinitely. Alerts go to files by default, and Filebeat reads alerts.json and sends the documents to the indexer.
Global and alerts options
The options from the first four rows, plus rotate_interval and max_output_size, belong to the <global> section, and log_alert_level and email_alert_level to the <alerts> section.
| Option | Default | Values | Effect |
|---|---|---|---|
logall | no | yes, no | Writes events, including those with no rule match, to archives.log |
logall_json | no | yes, no | The same to archives.json |
alerts_log | yes | yes, no | Writes alerts to alerts.log |
jsonout_output | yes | yes, no | Writes alerts in JSON to alerts.json |
log_alert_level | 3 | 1 to 16 | Minimum level of an alert written to alerts.log or alerts.json |
email_alert_level | 7 | 1 to 16 | Minimum level of an alert sent by email; the ossec.conf file installed with the manager sets 12 |
rotate_interval | 0 (disabled) | 10m to 1d | Interval between file rotations |
max_output_size | 0 (disabled) | 1M to 1 TiB, suffix M or G | Size limit for alert files |
Disabling jsonout_output stops alert indexing, because in a default installation Filebeat reads exactly alerts.json. The log_alert_level option answers the question of why a low-level rule matched an event and the alert is not in the file. Rule levels and thresholds are covered in the post on rule levels. Default configuration of the alerts section:
<alerts>
<log_alert_level>3</log_alert_level>
<email_alert_level>12</email_alert_level>
</alerts>
The 10m minimum comes from the analysisd.min_rotate_interval option in /var/ossec/etc/internal_options.conf. Examples from the documentation are <rotate_interval>10h</rotate_interval> and <max_output_size>20M</max_output_size>.
Enabling archive logging
You edit the options in /var/ossec/etc/ossec.conf on the Wazuh server. The documentation shows the full set of <global> fields, in which logall or logall_json enable archives:
<ossec_config>
<global>
<jsonout_output>yes</jsonout_output>
<alerts_log>yes</alerts_log>
<logall>yes</logall>
<logall_json>yes</logall_json>
</global>
</ossec_config>
You can set one of the options or both. Only logall_json lets you create an index for visualization in the dashboard. After the change, restart the manager and check that a file appeared in /var/ossec/logs/archives/:
systemctl restart wazuh-manager
ls -la /var/ossec/logs/archives/
Filebeat and the wazuh-archives-* pattern
A file written to disk does not reach the dashboard on its own. The documentation describes two steps on the indexing side.
- In
/etc/filebeat/filebeat.yml, changeenabledin thearchivessection fromfalsetotrue. - Restart Filebeat.
A configuration fragment from the indices page, with the alerts and archives modules active:
filebeat.modules:
- module: wazuh
alerts:
enabled: true
archives:
enabled: true
systemctl restart filebeat
filebeat test output
The filebeat test output command checks the connection to the indexer. The documentation shows in its output, among other things, the DNS and TLS checks and talk to server... OK. On the dashboard side:
- Open the menu in the top left corner, then Dashboard Management > Index patterns > Create index pattern.
- Enter
wazuh-archives-*as the pattern name and continue. - Choose
timestampas the time field. The documentation warns not to choose@timestamp. - Confirm with the Create index pattern button.
- In Explore > Discover, choose the
wazuh-archives-*pattern.
You can check the index state from the indexer (replace the parameters in angle brackets with your own):
curl -k -u <INDEXER_USERNAME>:<INDEXER_PASSWORD> "https://<INDEXER_IP_ADDRESS>:9200/_cat/indices/wazuh-archives-*?v"
Indices are created daily. Alert index names look like wazuh-alerts-4.x-2023.03.17. The name format is changed in the file /usr/share/filebeat/module/wazuh/archives/ingest/pipeline.json (likewise alerts/ingest/pipeline.json), in the date_index_name field and the date_rounding key. The documentation also describes creating a custom pattern next to the default wazuh-alerts-*, for example my-custom-alerts-*, by editing the manifest.yml files of the Filebeat modules.
File location and rotation
Current files are in /var/ossec/logs/archives/ (archives) and /var/ossec/logs/alerts/ (alerts). The manager compresses logs daily or after a threshold is exceeded (size, age, time), and after rotation it creates a new file with the original name. Compressed files are signed with MD5, SHA1 and SHA256 sums and go into nested directories by log name, year and month.
Example from the documentation: archives.log compressed on 13 April 2024 is in .../archives/2024/Apr/:
# ls -la /var/ossec/logs/archives/2024/Apr/
-rw-r----- 1 wazuh wazuh 0 Apr 13 00:00 ossec-archive-13.log.gz
-rw-r----- 1 wazuh wazuh 0 Apr 13 00:00 ossec-archive-13.log.sum
The prefix ossec and the day of the month are added to the name, and the checksum file has the .sum extension. The documentation allows deleting compressed files after a set time and moving them to a log management system, a backup server or cloud storage.
Rotation compresses files but does not delete them. Plan retention and space before enabling logall or logall_json, because according to the documentation archives contain logs from all monitored endpoints and take up a lot of space. Also decide who deletes or moves the compressed files, and after how long.
Archives in the analyst’s work
The documentation points out that when you browse the wazuh-archives-* pattern, some events are already visible as alerts, and the record also covers events that did not generate an alert. This is the basis of threat hunting and historical incident analysis. You can use an event from the archive to write a decoder and a rule, and then check them in wazuh-logtest.
Example hunt for technique T1218.010
Using signed binary proxy execution (T1218.010, abuse of regsvr32.exe) as an example, the documentation shows how to use archives. A Windows agent collects Sysmon through localfile with log_format equal to eventchannel, and the analyst proceeds in the dashboard like this:
- In Explore > Discover, picks the
wazuh-archives-*pattern. - Narrows the time range to a few minutes around the test and filters the events of one endpoint by
agent.id,agent.iporagent.name, for exampleagent-01. - Types
regsvr32in the search bar. - For a more precise result, applies the filter
data.win.eventdata.ruleName:technique_id=T1218.010,technique_name=Regsvr32. - Expands the event and views the full record in the JSON tab.
Among the hits, some events are already visible as alerts. The rest did not generate an alert and are material for your own rules. This flow fits the two roles of the archive well: historical review and detection design.
If an event is not in an archive that is enabled, and the agent claims it sent it, look for the cause before the analysis. This thread is covered in the post on losses in analysisd.
Choosing options for the goal
Recommendation: choose the smallest set of options that covers the need.
| Goal | Options | Note |
|---|---|---|
| Only alerts in the dashboard | Defaults: jsonout_output and alerts_log set to yes, logall and logall_json set to no | No archive disk cost |
| Hunting and review in the dashboard | logall_json set to yes, archives in Filebeat set to true, the wazuh-archives-* pattern | logall is not needed for the index |
| Text archive for searching outside the dashboard | logall set to yes | The archives.log file does not go into the index |
| Limiting the growth of alert files | rotate_interval or max_output_size | Both disabled by default |
Verification after a change
The order of checks follows the path of the event: file, Filebeat, index, view. Fill in the access data placeholders with your own.
# 1. Archive files exist after the manager restart
ls -la /var/ossec/logs/archives/
# 2. Filebeat reaches the indexer
filebeat test output
# 3. Daily archive indices exist
curl -k -u <INDEXER_USERNAME>:<INDEXER_PASSWORD> "https://<INDEXER_IP_ADDRESS>:9200/_cat/indices/wazuh-archives-*?v"
The first gap in this chain shows the stage to fix. The table below lists symptoms and checks.
Diagnostics by artifact
| Symptom | Check | What it confirms |
|---|---|---|
No archives.log | logall in <global>, manager restart | Writing in syslog format |
No archives.json | logall_json in <global>, manager restart | Writing in JSON |
archives.json exists, no view | archives with enabled: true, Filebeat restart, the wazuh-archives-* pattern with timestamp | Ingestion and the view |
| No alerts in the dashboard, files growing | filebeat test output, the alerts module | Connection to the indexer |
Alerts are not in alerts.json | jsonout_output and the rule level against log_alert_level | Writing and the threshold |
| The event is in the archive, no alert | Result in wazuh-logtest, rule level and groups | Rule match |
A dashboard pattern is a view configuration and does not enable writing or ingestion.
What the documentation does not specify
- Retention of the
wazuh-alerts-*andwazuh-archives-*indices and the schedule for deleting files. The retention time of archive files does not carry over to the indices. - The size, age or time thresholds that trigger rotation, and the names of rotated alert files.
- Measurements of the performance impact of
logallandlogall_json, apart from the warning about disk usage. - The behavior of the options on cluster nodes.
Sources
- https://documentation.wazuh.com/current/user-manual/manager/event-logging.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/global.html
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/alerts.html
- https://documentation.wazuh.com/current/user-manual/wazuh-indexer/wazuh-indexer-indices.html