Wazuh cluster: configuration, health checks and the limits of each test
Wazuh cluster: the cluster block with defaults, port 1516, cluster_control, the API, analysisd.state, filebeat test output and the limits of each check.
A green systemctl is-active wazuh-manager says only that systemd considers the unit running. It does not confirm that the worker is connected to the master, that analysisd is processing events or that an alert reached the index, so cluster health has to be checked in layers, knowing what each layer proves.
Cluster architecture
A Wazuh server cluster has exactly one master node and any number of workers. During synchronization the data from the master takes precedence. The master sends agent registration data, shared configuration, CDB lists, custom SCA policies and custom decoders and rules to the workers. A file changed locally on a worker is overwritten with the master’s version in the next synchronization cycle.
A change in /var/ossec/etc/ossec.conf made on the master has to be repeated by hand on the other nodes, because this file is not synchronized. A wider view of the components is in the post on Wazuh architecture.
Ports from the architecture documentation that matter for the cluster:
Port Protocol Purpose
1514 TCP agent connections
1515 TCP agent enrollment
1516 TCP Wazuh cluster daemon
55000 TCP Wazuh server API
9200 TCP Wazuh indexer API
The documentation calls 1516 the port of the cluster daemon, so the firewall between server nodes should allow it (a conclusion from the port description). Port 55000 serves health checks through the API, and 9200 serves queries for fresh alerts in the index.
The cluster block
The configuration sits in the <cluster> section of /var/ossec/etc/ossec.conf. The key is shared by all nodes, and the documentation gives a way to generate it: openssl rand -hex 16.
Option Default Values and notes
name wazuh any cluster name
node_name node01 unique in the cluster; with a duplicate one of the nodes is rejected
node_type master master or worker; the value client works but logs a warning
key none 32 characters: letters, digits, underscores; the same on all nodes
port 1516 from 1025 to 65534
bind_addr 127.0.0.1 IP address used for cluster traffic on hosts with several interfaces
nodes 127.0.0.1 master IP address or DNS name; one master allowed, extra entries are ignored
hidden no yes hides cluster information in alerts
disabled no yes means the cluster does not start
Two traps follow directly from the table. The default values of bind_addr and nodes are 127.0.0.1, so a node with an unchanged block will not connect to another server. The second problem is node_name: a duplicated name rejects one of the nodes, which looks like a missing worker in the list, not like a configuration error.
A worker example, with addresses from the documentation pool:
<cluster>
<name>example-cluster</name>
<node_name>example-worker-01</node_name>
<key>0123456789abcdef0123456789abcdef</key>
<node_type>worker</node_type>
<port>1516</port>
<bind_addr>0.0.0.0</bind_addr>
<nodes>
<node>192.0.2.10</node>
</nodes>
<hidden>no</hidden>
<disabled>no</disabled>
</cluster>
After a configuration change the documentation says to restart the service with systemctl restart wazuh-manager. For master and worker the block differs only in node_name and node_type, and <nodes> in both points to the master address.
Diagnosis order
The checks below are ordered from the closest to the node to the farthest from it. The order matters, because each next one answers a question the previous one cannot. A positive result at an early stage does not excuse you from the later ones: each of them can fail independently.
During an outage look for the first layer that gives a negative result, and narrow the diagnosis only there. When all node checks are green and the index lacks fresh documents, the problem lies outside the cluster: in transport or in the indexer itself.
Check 1: processes
sudo /var/ossec/bin/wazuh-control status
The command lists which Wazuh processes are running, for example wazuh-analysisd is running... or wazuh-clusterd not running.... The documentation recommends starting, stopping and restarting through systemctl or service, to avoid a mismatch between the service state and the process state.
What it proves: that the processes exist, including wazuh-clusterd. What it does not prove: that the processes do any work, that the cluster has all its nodes and that data flows on.
Check 2: membership and synchronization
sudo /var/ossec/bin/cluster_control -l
sudo /var/ossec/bin/cluster_control -i
sudo /var/ossec/bin/cluster_control -i more
sudo /var/ossec/bin/cluster_control -a
The tool works from any manager, but it requires a running wazuh-clusterd. The -l option lists the connected nodes in the columns NAME, TYPE, VERSION and ADDRESS. The -i option shows the health check: for each node, the times of the last integrity check, integrity synchronization, agent information, agent groups and the last keep alive. The -i more variant adds the version, type, number of active agents and number of synchronized files (Shared, Missing, Extra). The -a option lists agents, and -fn and -fs narrow the result to a node or an agent status.
What it proves: that the worker is visible to the master and that configuration synchronization has fresh timestamps. What it does not prove: that analysisd on the worker is not blocked and that alerts reach the indexer. The documentation gives no threshold for the age of synchronization that counts as unhealthy, so you have to set the threshold yourself by observing normal operation.
Check 3: the API
The API spec in version 4.14.0 describes three endpoints useful for monitoring. All require a JWT token and the permissions cluster:read or manager:read:
curl -sk -H "Authorization: Bearer ${TOKEN}" "https://example-master:55000/cluster/healthcheck"
curl -sk -H "Authorization: Bearer ${TOKEN}" "https://example-master:55000/cluster/nodes"
curl -sk -H "Authorization: Bearer ${TOKEN}" "https://example-master:55000/manager/status"
GET /cluster/nodes returns the name, type, version and address of each node. According to its description, GET /cluster/healthcheck returns the last keep alive, the time of the last synchronization and the number of agents reporting to each node. GET /manager/status returns the state of all Wazuh daemons as running or stopped. It is the remote equivalent of wazuh-control status, so it has the same limits.
An HTTP 200 response means that the API responds and the token is valid. It does not mean that event traffic is healthy. For processing numbers use GET /manager/daemons/stats with the daemons_list parameter, whose allowed values are wazuh-analysisd, wazuh-remoted and wazuh-db. There are also variants with a node identifier, /cluster/{node_id}/daemons/stats and /cluster/{node_id}/status, for checking a worker from the master.
Check 4: analysisd
The analysisd statistics file sits in /var/ossec/var/run/wazuh-analysisd.state and is refreshed every 5 seconds by default. The interval is changed by the value analysisd.state_interval in the internal configuration.
sudo rg "events_received|events_processed|events_dropped|alerts_written|queue_usage" /var/ossec/var/run/wazuh-analysisd.state
The documentation example contains, among others, events_received, events_processed, events_dropped, alerts_written and the pairs *_queue_usage and *_queue_size (size 16384 in the example). My own interpretation: event_queue_usage close to 1 suggests a full queue, and a growing events_dropped suggests event loss. A single reading is a snapshot, and event loss shows only in the difference between two readings over time. Empty queues at the moment of reading do not rule out that events were lost a moment earlier. The interpretation of lost events is developed in the post on events dropped by analysisd.
What it proves: that the analysis engine decodes and matches events and writes alerts. What it does not prove: that Filebeat picked them up and that the indexer indexed them. The documentation does not describe whether the counters reset on restart, so the difference is computed only between readings from one process run.
Check 5: Filebeat
sudo filebeat test output
According to the installation documentation, the command verifies that Filebeat connects correctly to the configured output. An example result for the indexer contains the successive steps: parse url... OK, connection..., dial up... OK. By default Filebeat sends alerts from the Wazuh server to the indexer.
What it proves: that the Filebeat output is reachable, the certificate is accepted and the indexer responds. What it does not prove: that Filebeat reads the current alerts file and that a specific alert reached the index. The test checks the connection, not the data flow.
Check 6: data freshness in the index
Only a query for the newest document closes the loop from the agent to the index. The sort option in OpenSearch takes field:direction pairs, and the response contains the sort values for each hit.
curl -sk -u "${INDEXER_USER}:${INDEXER_PASSWORD}" \
"https://example-indexer:9200/wazuh-alerts-4.x-*/_search?sort=timestamp:desc&size=1"
The index pattern wazuh-alerts-4.x-* comes from the indexer tuning documentation. The name of the time field in alert documents is not described on the pages used. The documentation gives timestamp as the time field for the archives index, so for alerts you have to check the name in the mapping before the result serves as an alarm. Compare the time of the newest document with the current time: a difference larger than the typical gap between alerts means a hole that none of the earlier checks shows. The rules for managing indices are described in the post on retention in OpenSearch.
The lack of fresh documents does not point to a cause. It can be the agent, remoted, analysisd, Filebeat or the indexer, and disconnected agents are covered in the post on agent disconnections.
How to use these checks in practice
My own recommendation: treat checks 1 to 3 as a membership check and checks 4 to 6 as a flow check. In continuous monitoring collect the differences of the wazuh-analysisd.state counters over time instead of single readings, and alert on the age of the newest document in the index. Leave the other checks for manual diagnosis after an alarm.
After each change in the <cluster> block repeat cluster_control -l on the master and on the worker, because the two views can differ. After changing rules, decoders or CDB lists on the master, check that the workers have the same files: the documentation guarantees that local changes are overwritten during synchronization, but it does not say how long this takes.
What each check proves
Check Proves Does not prove
wazuh-control status processes are running that they work and the cluster is complete
cluster_control -l, -i nodes visible, sync recent that analysisd processes events
GET /cluster/healthcheck API responds, keep alive that alerts reach the indexer
analysisd.state decoding, rules, queues that Filebeat delivered them
filebeat test output output reachable that the alert reached the index
_search sort desc size 1 fresh document in the index which layer failed when there is a gap
What the documentation does not specify
- The name of the time field in documents of the alerts index (the pages used describe only
timestampfor archives). - Whether the
analysisd.statecounters reset after a restart. - The thresholds above which the age of synchronization or queue fill counts as unhealthy.
- The result of
cluster_control -ifor a worker that is running but has a blockedanalysisd. - Whether
/cluster/healthcheckreflects the state of Filebeat or the indexer (according to its description it concerns cluster nodes).
Sources
- https://documentation.wazuh.com/current/user-manual/reference/ossec-conf/cluster.html
- https://documentation.wazuh.com/current/user-manual/wazuh-server-cluster/cluster-nodes-configuration.html
- https://documentation.wazuh.com/current/user-manual/wazuh-server-cluster/types-of-nodes.html
- https://documentation.wazuh.com/current/user-manual/reference/tools/cluster-control.html
- https://documentation.wazuh.com/current/user-manual/reference/tools/wazuh-control.html
- https://documentation.wazuh.com/current/getting-started/architecture.html
- https://documentation.wazuh.com/current/user-manual/reference/statistics-files/wazuh-analysisd-state.html
- https://documentation.wazuh.com/current/installation-guide/wazuh-server/step-by-step.html
- https://documentation.wazuh.com/current/user-manual/wazuh-indexer/wazuh-indexer-tuning.html
- https://docs.opensearch.org/latest/api-reference/search-apis/search/
- https://raw.githubusercontent.com/wazuh/wazuh/v4.14.0/api/api/spec/spec.yaml