PL EN
WB-3D97B984TLP:CLEARWazuh 4

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

StreamContentsOption in global or alertsFile or index
archives.logAll events in syslog format, including those with no rule matchlogall/var/ossec/logs/archives/archives.log
archives.jsonThe same events in JSONlogall_json/var/ossec/logs/archives/archives.json, wazuh-archives-* indices
alerts.logAlerts in text formatalerts_log/var/ossec/logs/alerts/alerts.log
alerts.jsonThe same alerts in JSONjsonout_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.

OptionDefaultValuesEffect
logallnoyes, noWrites events, including those with no rule match, to archives.log
logall_jsonnoyes, noThe same to archives.json
alerts_logyesyes, noWrites alerts to alerts.log
jsonout_outputyesyes, noWrites alerts in JSON to alerts.json
log_alert_level31 to 16Minimum level of an alert written to alerts.log or alerts.json
email_alert_level71 to 16Minimum level of an alert sent by email; the ossec.conf file installed with the manager sets 12
rotate_interval0 (disabled)10m to 1dInterval between file rotations
max_output_size0 (disabled)1M to 1 TiB, suffix M or GSize 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.

  1. In /etc/filebeat/filebeat.yml, change enabled in the archives section from false to true.
  2. 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:

  1. Open the menu in the top left corner, then Dashboard Management > Index patterns > Create index pattern.
  2. Enter wazuh-archives-* as the pattern name and continue.
  3. Choose timestamp as the time field. The documentation warns not to choose @timestamp.
  4. Confirm with the Create index pattern button.
  5. 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:

  1. In Explore > Discover, picks the wazuh-archives-* pattern.
  2. Narrows the time range to a few minutes around the test and filters the events of one endpoint by agent.id, agent.ip or agent.name, for example agent-01.
  3. Types regsvr32 in the search bar.
  4. For a more precise result, applies the filter data.win.eventdata.ruleName:technique_id=T1218.010,technique_name=Regsvr32.
  5. 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.

GoalOptionsNote
Only alerts in the dashboardDefaults: jsonout_output and alerts_log set to yes, logall and logall_json set to noNo archive disk cost
Hunting and review in the dashboardlogall_json set to yes, archives in Filebeat set to true, the wazuh-archives-* patternlogall is not needed for the index
Text archive for searching outside the dashboardlogall set to yesThe archives.log file does not go into the index
Limiting the growth of alert filesrotate_interval or max_output_sizeBoth 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

SymptomCheckWhat it confirms
No archives.loglogall in <global>, manager restartWriting in syslog format
No archives.jsonlogall_json in <global>, manager restartWriting in JSON
archives.json exists, no viewarchives with enabled: true, Filebeat restart, the wazuh-archives-* pattern with timestampIngestion and the view
No alerts in the dashboard, files growingfilebeat test output, the alerts moduleConnection to the indexer
Alerts are not in alerts.jsonjsonout_output and the rule level against log_alert_levelWriting and the threshold
The event is in the archive, no alertResult in wazuh-logtest, rule level and groupsRule 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-* and wazuh-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 logall and logall_json, apart from the warning about disk usage.
  • The behavior of the options on cluster nodes.

Sources

↑↓ select Enter open Esc close