Log data analysis

Log data analysis involves reviewing logs generated by network devices, endpoints, and applications to gain visibility into an IT infrastructure. This visibility extends to multiple areas, including threat detection, system performance monitoring, troubleshooting, compliance auditing, and identifying anomalous activities. Log data analysis in Wazuh involves three phases:

  • Pre-decoding

  • Decoding

  • Rule matching

To illustrate the phases, let's consider a sample log entry:

Feb 14 12:19:04 sshd[25474]: Accepted password for Stephen from port 49765 ssh2


In the pre-decoding phase, the log analysis engine extracts syslog-like information such as timestamp, hostname, and program name from the log header.

Extracted information:

timestamp: 'Feb 14 12:19:04'
hostname: ''
program_name: 'sshd'


In the decoding phase, the log analysis engine looks for a decoder that matches the sample log. The decoders below match the sample log. These decoders are in the /var/ossec/rulesets/decoders/0310-ssh_decoders.xml file on the Wazuh server:

<decoder name="sshd">

<decoder name="sshd-success">
  <regex offset="after_prematch">^ \S+ for (\S+) from (\S+) port (\S+)</regex>
  <order>user, srcip, srcport</order>
  <fts>name, user, location</fts>

The decoder sshd matches the program name sshd, while the decoder ssh-success extracts Stephen,, and 49765 from the sample log.

Extracted information:

dstuser: 'Stephen'
srcip: ''
srcport: '49765'

To learn more about decoders, see the decoders syntax section.

Rule matching

In this phase, the Wazuh server compares the logs against a ruleset. Rule 5715 matches the sample log. This rule is in the /var/ossec/ruleset/rules/0095-sshd_rules.xml file on the Wazuh server.

<rule id="5715" level="3">
  <description>sshd: authentication success.</description>

By default, the Wazuh server generates alerts for any rule whose level is above 2. In this scenario, the log triggers an alert because the rule level is 3 and this will be visible on the Wazuh dashboard.

You can create custom decoders and rules to analyze logs that are not supported by default. To learn how to create custom rules and decoders, refer to custom rules and decoders.