TExcelTAD
Home › Defensive Security: SOC, SIEM, Detection Engineering & Threat Hunting › A Wazuh Lab: Manager, Agents and Log Collection

A Wazuh Lab: Manager, Agents and Log Collection

Everything so far ran on synthetic data in your browser. A SOC analyst also needs to have set up the real plumbing once: install a SIEM, enrol agents on Linux and Windows machines, collect the right logs and watch the first alerts arrive. Wazuh is a good platform for that lab: free and open source, with agents for Linux, Windows and macOS, a default rule set for authentication, Sysmon, file integrity and more, and a web dashboard. This lesson and the next build the SOC lab project of the course in your own isolated lab (Hypervisors, VM Networks and Snapshots): this one installs and collects, the next writes a rule and handles a simulated incident. The commands are shown as lab-session transcripts (Wazuh can't run in this site's sandbox); the collection check at the end runs in your browser.

The lab

Machine Address Role
wazuh.lab.test 10.10.0.50 Wazuh server (manager), indexer and dashboard, all in one VM (4 vCPU, 8 GB RAM, 50 GB disk is a comfortable lab size)
web01.lab.test 10.10.0.10 Ubuntu server with SSH and a web app: Linux agent
dc01.lab.test 10.10.0.20 Windows Server domain controller of lab.test: Windows agent, Sysmon
ws02.lab.test 10.10.0.22 Windows 11 workstation: Windows agent, Sysmon

All on a host-only or internal network, with snapshots taken before installation. Nothing in this lab is exposed to the Internet.

Architecture

Wazuh has three central components and the agents:

  • Wazuh server (manager): receives events from agents, decodes them (decoders extract fields), matches them against rules (XML), and produces alerts with a level from 0 to 15. It also runs active-response scripts and the API.
  • Wazuh indexer: a search engine (derived from OpenSearch) that stores alerts and events.
  • Wazuh dashboard: the web interface (derived from OpenSearch Dashboards) for searching, dashboards and agent management.
  • Agents: collect logs, file integrity, inventory and configuration data on each host and send them to the server, by default over TCP port 1514 (events) after enrolling over 1515; the server API listens on 55000.

For a lab, all three central components fit on one VM; production separates and clusters them.

Installing the server

The project provides an installation assistant that installs all central components on one host. The download path names the release (4.14 was current when this lesson was written; take the path from the official quickstart before you run it), and in a lab without Internet, download the packages on the host first:

console
lab session (wazuh.lab.test, 10.10.0.50, Ubuntu; scope: the isolated lab network only)
$ curl -sO https://packages.wazuh.com/4.14/wazuh-install.sh
$ sudo bash ./wazuh-install.sh -a
INFO: Starting Wazuh installation assistant.
INFO: --- Wazuh indexer ---
INFO: Wazuh indexer installation finished.
INFO: --- Wazuh server ---
INFO: Wazuh manager installation finished.
INFO: --- Wazuh dashboard ---
INFO: You can access the web interface https://10.10.0.50:443
    User: admin
    Password: <generated, shown once: store it in the lab password manager>
INFO: Installation finished.

A Docker deployment (the project's single-node Compose setup) is an alternative that keeps the lab host clean. Either way, change the generated passwords' storage to your lab vault, and take a snapshot.

Enrolling agents

On the Linux server, the agent package is installed with the manager's address set, then enabled:

console
lab session (web01.lab.test, 10.10.0.10)
$ sudo WAZUH_MANAGER='10.10.0.50' WAZUH_AGENT_NAME='web01' apt-get install ./wazuh-agent_4.x_amd64.deb
$ sudo systemctl enable --now wazuh-agent
$ sudo grep -E 'Connected to the server|Requesting a key' /var/ossec/logs/ossec.log | tail -2
... wazuh-agentd: INFO: Requesting a key from server: 10.10.0.50
... wazuh-agentd: INFO: (4102): Connected to the server ([10.10.0.50]:1514/tcp).

On Windows, the MSI takes the same parameters, then the service is started (an elevated PowerShell on ws02 and dc01):

console
lab session (ws02.lab.test, 10.10.0.22, elevated PowerShell)
PS> msiexec.exe /i wazuh-agent-4.x.msi /q WAZUH_MANAGER="10.10.0.50" WAZUH_AGENT_NAME="ws02"
PS> NET START WazuhSvc
The Wazuh service was started successfully.

On the server, agent_control lists the agents and their state:

console
lab session (wazuh.lab.test)
$ sudo /var/ossec/bin/agent_control -l
Wazuh agent_control. List of available agents:
   ID: 000, Name: wazuh (server), IP: 127.0.0.1, Active/Local
   ID: 001, Name: web01, IP: any, Active
   ID: 002, Name: ws02, IP: any, Active
   ID: 003, Name: dc01, IP: any, Active

Collecting the right logs

What each agent reads is set in its ossec.conf (or centrally, per agent group, in the server's agent.conf). Linux: the authentication log (or journald) and the web server's access log. Windows: the Security channel and Sysmon's channel, which needs Sysmon installed with a configuration first (Sysmon and auditd Configuration Basics):

xml
<!-- web01: /var/ossec/etc/ossec.conf (excerpt) -->
<localfile>
  <log_format>syslog</log_format>
  <location>/var/log/auth.log</location>
</localfile>
<localfile>
  <log_format>apache</log_format>
  <location>/var/log/nginx/access.log</location>
</localfile>

<!-- ws02 and dc01: C:\Program Files (x86)\ossec-agent\ossec.conf (excerpt) -->
<localfile>
  <location>Security</location>
  <log_format>eventchannel</log_format>
</localfile>
<localfile>
  <location>Microsoft-Windows-Sysmon/Operational</location>
  <log_format>eventchannel</log_format>
</localfile>

On the DC, also enable the advanced audit policy subcategories the detections need (account logon, account management, directory service changes; see Event Log Channels and the Audit Policy). Restart the agents after configuration changes.

Checking that collection works

Before writing any rule, prove each source arrives. Generate one known event per source in the lab (a failed SSH login to web01 with a non-existent user, a failed Windows sign-in on ws02, starting notepad.exe for a Sysmon Event ID 1), then look at the alerts the server wrote to /var/ossec/logs/alerts/alerts.json, one JSON object per line. One catch: Wazuh's default rule for Sysmon Event ID 1 (61603) has level 0, and level-0 rules never write an alert, so an ordinary process start is invisible in alerts.json. For the check, a lab-only rule in local_rules.xml raises the test event to level 3 (remove it afterwards, or check the event in the archive log instead):

xml
<group name="local,sysmon,">
  <rule id="100010" level="3">
    <if_sid>61603</if_sid>
    <field name="win.eventdata.image" type="pcre2">(?i)\\notepad\.exe
lt;/field> <description>lab: Sysmon Event 1 collection check (notepad.exe)</description> </rule> </group>

The program below runs the check on a synthetic extract of alerts.json in the format Wazuh writes (fields shortened).

python · try it yourself
import json
import pandas as pd

ALERTS = """\
{"timestamp":"2026-01-15T10:00:03.120+0000","agent":{"id":"001","name":"web01"},"rule":{"id":"5710","level":5,"description":"sshd: Attempt to login using a non-existent user","groups":["syslog","sshd","authentication_failed","invalid_login"]},"data":{"srcip":"10.10.0.66","srcuser":"oracle"}}
{"timestamp":"2026-01-15T10:01:10.551+0000","agent":{"id":"002","name":"ws02"},"rule":{"id":"60122","level":5,"description":"Logon Failure - Unknown user or bad password","groups":["windows","windows_security","authentication_failed"]},"data":{"win":{"system":{"eventID":"4625"},"eventdata":{"targetUserName":"erin","ipAddress":"10.10.0.66"}}}}
{"timestamp":"2026-01-15T10:02:44.903+0000","agent":{"id":"002","name":"ws02"},"rule":{"id":"100010","level":3,"description":"lab: Sysmon Event 1 collection check (notepad.exe)","groups":["local","sysmon"]},"data":{"win":{"system":{"eventID":"1"},"eventdata":{"image":"C:\\\\Windows\\\\System32\\\\notepad.exe"}}}}
{"timestamp":"2026-01-15T10:03:20.004+0000","agent":{"id":"001","name":"web01"},"rule":{"id":"31101","level":5,"description":"Web server 400 error code.","groups":["web","accesslog","attack"]},"data":{"srcip":"10.10.0.66","url":"/admin"}}
"""
EXPECTED = {  # source -> (agent, rule group that proves it arrives)
    "Linux auth log":     ("web01", "sshd"),
    "web access log":     ("web01", "accesslog"),
    "Windows Security":   ("ws02", "windows_security"),
    "Sysmon on ws02":     ("ws02", "sysmon"),
    "Windows Security DC": ("dc01", "windows_security"),
    "Sysmon on dc01":     ("dc01", "sysmon"),
}
rows = [json.loads(line) for line in ALERTS.splitlines()]
df = pd.DataFrame({"agent": [r["agent"]["name"] for r in rows], "rule": [r["rule"]["id"] for r in rows],
                   "level": [r["rule"]["level"] for r in rows], "groups": [r["rule"]["groups"] for r in rows]})
print(df.assign(groups=df.groups.str.join(",")).to_string(index=False))
print()
for source, (agent, group) in EXPECTED.items():
    ok = ((df.agent == agent) & df.groups.apply(lambda g: group in g)).any()
    print(f"{source:20} {'arriving' if ok else 'MISSING: check agent, ossec.conf, audit policy'}")
agent   rule  level                                          groups
web01   5710      5 syslog,sshd,authentication_failed,invalid_login
 ws02  60122      5  windows,windows_security,authentication_failed
 ws02 100010      3                                    local,sysmon
web01  31101      5                            web,accesslog,attack

Linux auth log       arriving
web access log       arriving
Windows Security     arriving
Sysmon on ws02       arriving
Windows Security DC  MISSING: check agent, ossec.conf, audit policy
Sysmon on dc01       MISSING: check agent, ossec.conf, audit policy

Four test events, four alerts, and the check says what the dashboard would not: dc01 sends nothing. ws02 and web01 prove every one of their sources (the invalid SSH user produced rule 5710, the failed Windows logon 60122, notepad.exe the lab rule 100010 on top of Sysmon's process-creation rule, and a request for /admin a web 400 alert), but no alert carries dc01's name. The usual causes, in order: the agent is not connected, its ossec.conf lacks the channels, Sysmon is not installed, or the audit policy does not write the events. A SOC runs this same check continuously, as a heartbeat per source (Log Sources). Rule IDs and group names here follow Wazuh 4.x's default rule set; check them against your version's ruleset/rules directory.

Securing the lab SIEM itself

A SIEM holds every secret that ever reached a log. Even in a lab, practise the habits: change default and generated passwords, restrict the dashboard and API (ports 443 and 55000) to the admin network, keep agents' enrolment protected (an enrolment password, or certificates), patch the server, and back up its configuration and rules (they are the work you will want to keep).

Pitfalls

  • Under-sized lab VM. The indexer needs memory; with less than about 4 GB the components fail in confusing ways.
  • Forgetting Sysmon. The Sysmon localfile block collects nothing until Sysmon is installed on the host.
  • Testing without generating events. An empty dashboard proves nothing; generate a known event per source and check each.

Practice

1. Which ports must the lab firewall allow from agents to the server, and which only from the admin network?

From agents: 1514/TCP (events) and 1515/TCP (enrolment). From the admin network only: 443 (dashboard) and 55000 (server API). The indexer's port (9200) only needs to be reachable between the central components.

2. dc01 shows no alerts at all. List the checks in order.

agent_control -l on the server (is agent 003 active?); the agent's own ossec.log on dc01 (connected? errors?); the localfile blocks in its configuration (Security and Sysmon present?); Sysmon installed and its channel existing; the audit policy (are the events being written at all?); finally generate a known event (a failed logon) and look for it.

3. Why use Wazuh's agent groups and `agent.conf` instead of editing every agent's `ossec.conf`?

Central configuration: all Windows workstations get the same collection settings from the server, changes are made once, and new agents inherit them by joining the group. Per-host edits drift.

Test yourself

What does the Wazuh server (manager) do with incoming events?

  1. Stores them only
  2. Decodes them into fields, matches rules and produces alerts with levels 0-15
  3. Forwards them to the Internet
  4. Deletes duplicates only

Which agent configuration collects Sysmon events on Windows?

  1. A syslog localfile for C:\Windows
  2. A localfile with location Microsoft-Windows-Sysmon/Operational and log_format eventchannel
  3. Nothing; Wazuh reads Sysmon automatically
  4. A rule in local_rules.xml

In the collection check, which sources were missing?

  1. None
  2. Both dc01 sources: its Security log and Sysmon
  3. Only the web access log
  4. Everything on ws02

Why generate one known event per source before writing rules?

  1. To fill the disk
  2. An empty view proves nothing; a known event shows the whole path from host to alert works
  3. Wazuh requires it to start
  4. To test the network speed