Wazuh 4 training, part 1: server, dashboard and API
Wazuh 4 training part 1: server components, dashboard menu, log_alert_level and enrollment password in ossec.conf, API token, custom dashboard, PDF report.
The first part of the Wazuh 4 training covers the server and the dashboard before the first agent joins the lab. The exercises include the dashboard menu, two changes in ossec.conf, checking and securing the server API, and a custom dashboard with a PDF report, with every option checked against the Wazuh 4.14 documentation.
What the Wazuh server consists of
The documentation splits the platform into four components: Wazuh indexer, Wazuh server, Wazuh dashboard and Wazuh agent. The “Wazuh server” itself covers three elements running on one host:
| Element | Role |
|---|---|
| Wazuh manager | receives events from agents, decodes them and matches rules (analysis engine) |
| Wazuh server API | REST API of the manager, used by the dashboard for configuration and status |
| Filebeat | reads the manager output and sends alerts and events to the indexer over TLS |
The data flow looks like this: the agent sends events to the agent connection service, the manager analyzes them, Filebeat forwards the result to the indexer, and the dashboard queries the indexer for visualization data and the server API for configuration and agent status. Agent-server communication is encrypted with AES by default (128-bit blocks, 256-bit keys). Details and cluster variants are in the post on Wazuh architecture.
Default ports to open in the lab:
| Component | Port | Service |
|---|---|---|
| Wazuh server | 1514/TCP | agent connections |
| Wazuh server | 1515/TCP | agent enrollment |
| Wazuh server | 1516/TCP | cluster daemon |
| Wazuh server | 55000/TCP | Wazuh server RESTful API |
| Wazuh indexer | 9200/TCP | Wazuh indexer RESTful API |
| Wazuh indexer | 9300-9400/TCP | indexer cluster communication |
| Wazuh dashboard | 443/TCP | web interface |
Port 1514/UDP for agents and the syslog collector on 514 exist, but are disabled by default.
Some features also need outbound internet traffic. If the lab restricts outbound traffic, the documentation lists three connections to allow:
| Source | Destination | Port | Purpose |
|---|---|---|---|
| Wazuh server | cti.wazuh.com | 443/TCP | vulnerability detection feed updates and the Wazuh update check service |
| Wazuh server | packages.wazuh.com | 443/TCP | WPK packages for remote agent upgrades |
| all central components | packages.wazuh.com | 443/TCP | installation and upgrade of the central components |
Without access to cti.wazuh.com the vulnerability detection module has no CVE data; for such an environment the documentation describes an offline mode. This matters in part 8, and WPK packages come back in part 3 with remote agent upgrades.
Exercise 1: first login and navigation
After logging in to the dashboard, the menu opens with the ☰ icon in the top left corner. Sections that come back in later parts of the training:
| Menu section | Contents |
|---|---|
| Endpoint security | Configuration Assessment, Malware Detection, File Integrity Monitoring |
| Threat intelligence | Threat Hunting, Vulnerability Detection, MITRE ATT&CK |
| Security operations | IT Hygiene and compliance: PCI DSS, GDPR, HIPAA, NIST 800-53, TSC |
| Cloud security | Docker, Amazon Web Services, Google Cloud, GitHub, Office 365, Microsoft Graph Services |
| Agents management | Summary (agent list and deployment), Endpoint Groups |
| Server management | Rules, Decoders, CDB lists, Status, Cluster, Statistics, Logs, Settings, Dev Tools, Ruleset Test, Security |
| Indexer management | Index and Snapshot Management, Security, Sample Data, Dev Tools |
| Dashboard management | Dashboard Management, Reporting, Server APIs, App Settings, About |
The two “Dev Tools” entries do different things. The one in Server management sends requests to the Wazuh server API (agents, inventory, vulnerabilities). The one in Indexer management sends requests to the indexer (cluster, data in indices).
Tasks:
- Open Server management > Status and check that the manager daemons are running.
- Open Server management > Logs: this is a view of the
/var/ossec/logs/ossec.logfile from the manager. - Open Explore > Discover and select the
wazuh-alerts-*pattern. Without agents you will see only alerts of the manager itself. - If you want to see module dashboards before connecting agents, add sample data in Indexer management > Sample Data.
The index template from the Wazuh repository (tag v4.14.1) covers the patterns wazuh-alerts-4.x-* and wazuh-archives-4.x-*. The difference between these indices is described in the post on archives and alerts.
Exercise 2: changes in ossec.conf from the dashboard
The main manager configuration file is /var/ossec/etc/ossec.conf. From the dashboard you edit it in Server management > Settings. In this exercise you change two options.
log_alert_level
The option in the <alerts> section sets the minimum level of an alert written to alerts.log and alerts.json. The default value is 3. Default configuration from the documentation:
<alerts>
<log_alert_level>3</log_alert_level>
<email_alert_level>12</email_alert_level>
</alerts>
In the training lab the threshold is lowered to 1, so that later exercises also show alerts of levels 1 and 2:
<alerts>
<log_alert_level>1</log_alert_level>
<email_alert_level>12</email_alert_level>
</alerts>
This is a lab setting. A lower threshold means more alerts in the manager files and in the indexer. Rules have levels from 0 to 16; the meaning of each threshold is covered in the post on rule levels.
Agent enrollment password
The <auth> section controls the agent enrollment service (port 1515). The use_password option turns on a shared password and defaults to no. After changing it to yes, the manager reads the password from the /var/ossec/etc/authd.pass file. When the file does not exist, the service generates a random password at every manager restart and writes it to /var/ossec/logs/ossec.log. The documentation recommends your own password in the file:
<auth>
<use_password>yes</use_password>
</auth>
# Create the enrollment password file on the manager (run as root)
echo "<CUSTOM_PASSWORD>" > /var/ossec/etc/authd.pass
chmod 640 /var/ossec/etc/authd.pass
chown root:wazuh /var/ossec/etc/authd.pass
systemctl restart wazuh-manager
systemctl status wazuh-manager
Permissions 640 and the root:wazuh owner come from the documentation. An agent that is to enroll needs the same password on its side; part 2 of the training deals with that, and all enrollment options are described in the post on agent enrollment.
Before you change use_password, review the whole section in its default form from the documentation. It shows what else the enrollment service does without any configuration:
<auth>
<disabled>no</disabled>
<remote_enrollment>yes</remote_enrollment>
<port>1515</port>
<use_source_ip>no</use_source_ip>
<force>
<enabled>yes</enabled>
<disconnected_time enabled="yes">1h</disconnected_time>
<after_registration_time>1h</after_registration_time>
<key_mismatch>yes</key_mismatch>
</force>
<purge>yes</purge>
<use_password>no</use_password>
<ciphers>HIGH:!ADH:!EXP:!MD5:!RC4:!3DES:!CAMELLIA:@STRENGTH</ciphers>
<!-- <ssl_agent_ca></ssl_agent_ca> -->
<ssl_verify_host>no</ssl_verify_host>
<ssl_manager_cert>etc/sslmanager.cert</ssl_manager_cert>
<ssl_manager_key>etc/sslmanager.key</ssl_manager_key>
<ssl_auto_negotiate>no</ssl_auto_negotiate>
</auth>
The <force> block decides what happens when an agent enrolls with a name or IP address the manager already knows. In a lab this happens often, because virtual machines are restored from snapshots:
| Option | Default | Meaning according to the documentation |
|---|---|---|
enabled | yes | forces the insertion of an agent with a duplicate name or IP address; the old agent with the same name or address is removed |
disconnected_time | 1h, enabled="yes" | replacement only of an agent disconnected longer than the given time; enabled="no" forces replacement even of an active agent, value 0 replaces any disconnected agent |
after_registration_time | 1h | replacement only when more than the given time has passed since registration; 0 means always |
key_mismatch | yes | replacement when the agent key differs from the key registered in the manager |
purge | yes | deletion of client keys when agents are removed |
Times accept the suffixes s, m, h and d. With the default values, an agent restored from a snapshot right after its first enrollment will not replace its entry until an hour has passed since registration. If you rebuild agents often in the lab, you can lower these thresholds. I keep the defaults, because part 2 relies on them.
Exercise 3: checking the server API
The dashboard uses the server API on port 55000, so a working API is a precondition for the later parts. Every request needs a JWT token. The raw=true parameter returns the token alone as text, which makes it easy to store in a shell variable:
# Get a JWT token and call the API root endpoint
TOKEN=$(curl -u <WAZUH_API_USER>:<WAZUH_API_PASSWORD> -k -X POST "https://localhost:55000/security/user/authenticate?raw=true")
curl -k -X GET "https://localhost:55000/?pretty=true" -H "Authorization: Bearer $TOKEN"
The response includes the fields title (“Wazuh API REST”), api_version, license_name, hostname and timestamp. The -k parameter is needed when the API uses the default self-signed certificates.
Notes from the documentation:
- The default API credentials are
wazuh:wazuhand must be changed after installation. - After an installation with the script, the API user is
wazuhand the password is in thewazuh-install-files.tararchive, in thewazuh-install-files/wazuh-passwords.txtfile. - Token lifetime is set by
auth_token_exp_timeout, in seconds. It can be read and changed only through theGET /security/configandPUT /security/configendpoints, andDELETE /security/configrestores the default values; the sample response in the documentation shows the value 900.
# Read the current API security settings (token lifetime, RBAC mode)
curl -k -X GET "https://localhost:55000/security/config?pretty=true" -H "Authorization: Bearer $TOKEN"
You can run the same request without a manual token in Server management > Dev Tools: the dashboard handles authentication itself, you only type GET / and run it. From there it is also easy to check GET /agents once agents appear in part 2.
Exercise 4: securing the server API
The server API has full access to the manager configuration, so the documentation gives its hardening a separate page. The configuration is in the /var/ossec/api/configuration/api.yaml file. Most settings there are commented out by default; you change one by uncommenting and editing the line. An excerpt with the default values from the documentation:
host: ['0.0.0.0', '::']
port: 55000
drop_privileges: yes
experimental_features: no
max_upload_size: 10485760
authentication_pool_size: 2
intervals:
request_timeout: 10
https:
enabled: yes
key: "server.key"
cert: "server.crt"
use_ca: False
ca: "ca.crt"
ssl_protocol: "auto"
ssl_ciphers: ""
access:
max_login_attempts: 50
block_time: 300
max_request_per_minute: 300
Options related to security:
| Option | Default | Meaning according to the documentation |
|---|---|---|
host | ['0.0.0.0', '::'] | the API accepts connections on all interfaces; narrowing the list restricts access |
port | 55000 | API port |
request_timeout | 10 | maximum response time for one request, in seconds |
max_login_attempts | 50 | limit of login attempts from one IP address within block_time |
block_time | 300 | window in seconds; after the attempt limit is exceeded the IP address is blocked until the end of the window |
max_request_per_minute | 300 | limit of requests per minute for all endpoints except authentication; 0 disables the limit |
The max_request_per_minute limit is global: once it is reached, the API rejects requests from every user until the end of the minute. For POST /events the effective value is 30 if you set more than 30.
The documentation recommends five changes after installation:
- A trusted certificate instead of the self-signed one. When there is no certificate in
/var/ossec/api/configuration/ssl/, the server generates a key and a self-signed certificate at startup. With theplainlog format, these entries then appear in/var/ossec/logs/api.log:
INFO: HTTPS is enabled but cannot find the private key and/or certificate. Attempting to generate them.
INFO: Generated private key file in WAZUH_PATH/api/configuration/ssl/server.key.
INFO: Generated certificate file in WAZUH_PATH/api/configuration/ssl/server.crt.
- Changing the default passwords of the administrative users
wazuhandwazuh-wuiwithPUT /security/users/{user_id}. The password must be 8 to 64 characters long and contain at least one uppercase letter, lowercase letter, number and symbol. - Narrowing
hostand optionally changingport. - Limiting the number of requests with
max_request_per_minute. - Limiting login attempts with
max_login_attemptsandblock_time, as protection against brute force attacks.
Changing a password takes two requests: a list of users with their IDs, and the password change for the chosen user:
# List API users with their IDs
curl -k -X GET "https://localhost:55000/security/users?pretty=true" -H "Authorization: Bearer $TOKEN"
# Change the password of one user
curl -k -X PUT "https://localhost:55000/security/users/<USER_ID>" -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"password": "<NEW_PASSWORD>"}'
The wazuh-wui user is the account the dashboard uses to connect to the API. After its password changes, the dashboard connection stops working until you enter the new credentials in /usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml. In the lab I change the wazuh password first, and wazuh-wui only together with an edit of that file.
Every change in api.yaml requires an API restart, which is done by restarting the manager service:
# Apply api.yaml changes (the API restarts with the manager)
systemctl restart wazuh-manager
In a cluster the master does not send its api.yaml to the workers. Each node has its own API configuration, so the change must be repeated on every worker, taking care not to overwrite the local IP address and port.
Exercise 5: custom dashboard
Visualizations in the Wazuh dashboard come from OpenSearch Dashboards. You create each one in Explore > Visualize > Create new visualization, with the wazuh-alerts-* index pattern, and at the end you click Update and Save. Three visualizations from the Wazuh documentation examples:
| Type | Metrics | Buckets |
|---|---|---|
| Data Table | Max of rule.level, Max of rule.firedtimes | none |
| Horizontal Bar | Count | X-axis: Terms on rule.mitre.tactic, Order by Metric: Count, Descending, Size 10 |
| Line | Max of rule.level | X-axis: Date Histogram on timestamp, Minimum interval: Minute |
The training exercise uses other fields of the same index: a table of alert counts split by agent.name and rule.description, a histogram of rule.level and a bar chart by GeoLocation.city_name. All these fields are in the Wazuh index template. The training material notes that GeoLocation.city_name has a value only in alerts with a public source address, so in a lab without internet traffic this chart may stay empty.
You assemble the dashboard in Explore > Dashboards > Create new dashboard. The Add an existing button adds saved visualizations, and Save in the top right corner saves the dashboard.
Exercise 6: PDF report on demand and on a schedule
Reports are handled by the Reporting plugin from OpenSearch Dashboards. From an open dashboard, the Reporting menu on the top bar generates a report: PDF or PNG for dashboards and visualizations, CSV or XLSX for saved searches from Discover. Generation runs in the background and can take a few minutes.
A recurring report needs a report definition:
- In the Report definitions section select Create.
- Enter a name, and as Report source select Dashboard and the dashboard from exercise 5.
- Set the time range, for example the last 7 days, and the PDF format.
- Optionally add a header and footer (only for dashboard, visualization and notebook reports).
- In Report trigger leave On demand and save. Then edit the definition and change the trigger to Schedule: Recurring (daily or at a set interval) or Cron based.
Generated reports are in Dashboard management > Reporting. Deleting a definition does not delete reports already generated, and single reports cannot be deleted. Definitions can also be handled through the plugin API, for example from the indexer Dev Tools:
GET _plugins/_reports/definitions
If a report is not created, the OpenSearch documentation points to two causes: the wrong headless Chrome version for the system the dashboard runs on, or its missing dependencies. UTF-8 characters that look fine in the browser but disappear in the report mean missing fonts on the system.
Checklist after part 1
- Manager daemon status checked in Server management > Status.
-
log_alert_levelset to 1 (lab only). -
use_passwordset toyes,authd.passwith permissions 640 and ownerroot:wazuh. - JWT token obtained,
GET /returns “Wazuh API REST”. -
auth_token_exp_timeoutread fromGET /security/config. -
api.yamlreviewed,accesslimits known, password of thewazuhuser changed. -
<force>block in<auth>reviewed before agent enrollment. - Three visualizations and a dashboard saved.
- One PDF report generated on demand and one definition with a schedule.
In part 2 Linux and Windows agents join the manager: package deployment variables, the agent-auth tool and automatic enrollment with the password set in this part.
What the documentation does not specify
- The
log_alert_levelpage does not say how the threshold affects the content of thewazuh-archives-*index; it describes only thealerts.logandalerts.jsonfiles. - The Wazuh documentation does not describe the Reporting plugin separately; the steps in this part come from the current OpenSearch Dashboards documentation, and menu names in the Wazuh dashboard may differ from it.
- The 4.14 documentation does not describe when the manager fills the
GeoLocationfields; theuse_geoipoption in the<alerts>section is marked as deprecated since version 2.0.
Sources
- https://documentation.wazuh.com/4.14/getting-started/components/index.html
- https://documentation.wazuh.com/4.14/getting-started/architecture.html
- https://documentation.wazuh.com/4.14/user-manual/wazuh-dashboard/navigating-the-wazuh-dashboard.html
- https://documentation.wazuh.com/4.14/user-manual/wazuh-dashboard/creating-custom-dashboards.html
- https://documentation.wazuh.com/4.14/user-manual/reference/ossec-conf/alerts.html
- https://documentation.wazuh.com/4.14/user-manual/reference/ossec-conf/auth.html
- https://documentation.wazuh.com/4.14/user-manual/agent/agent-enrollment/security-options/using-password-authentication.html
- https://documentation.wazuh.com/4.14/user-manual/api/getting-started.html
- https://documentation.wazuh.com/4.14/user-manual/api/configuration.html
- https://documentation.wazuh.com/4.14/user-manual/api/securing-api.html
- https://github.com/wazuh/wazuh/blob/v4.14.1/extensions/elasticsearch/7.x/wazuh-template.json
- https://docs.opensearch.org/latest/dashboards/reporting/report-dashboard-index/