1232 words
6 minutes
Wazuh 4.12.0 + OpenSearch 2.19.2 + Filebeat Integration Guide
Anubhav Gain
2025-01-28
2025-06-28
Wazuh 4.12.0 + OpenSearch 2.19.2 + Filebeat Integration Guide
Complete Setup for Alert Correlation and Advanced Visualization
Table of Contents
Architecture Overview
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐│ Wazuh Agent │ │ Wazuh Agent │ │ Wazuh Agent ││ (Endpoints) │ │ (Endpoints) │ │ (Endpoints) │└─────────┬───────┘ └─────────┬───────┘ └─────────┬───────┘ │ │ │ └──────────────────────┼──────────────────────┘ │ ┌─────────────▼─────────────┐ │ Wazuh Manager │ │ (4.12.0) │ │ - Alert Processing │ │ - Rule Engine │ │ - Correlation Engine │ └─────────────┬─────────────┘ │ ┌─────────▼─────────┐ │ Filebeat │ │ (Official) │ │ - Data Shipping │ │ - SSL/TLS │ └─────────┬─────────┘ │ ┌─────────────▼─────────────┐ │ OpenSearch │ │ (2.19.2) │ │ - Data Storage │ │ - Full-text Search │ │ - Aggregations │ └─────────────┬─────────────┘ │ ┌─────────────▼─────────────┐ │ OpenSearch Dashboards │ │ (2.19.2) │ │ - Visualizations │ │ - Custom Dashboards │ │ - Real-time Monitoring │ └───────────────────────────┘
Prerequisites
System Requirements
- OS: Ubuntu 20.04/22.04 LTS, CentOS 7/8, RHEL 7/8
- RAM: Minimum 8GB (16GB recommended for production)
- CPU: 4+ cores
- Disk: 100GB+ available space
- Network: All nodes should communicate on required ports
Required Ports
Service | Port | Protocol | Description |
---|---|---|---|
Wazuh Manager | 1514 | TCP/UDP | Agent communication |
Wazuh Manager | 1515 | TCP | Agent enrollment |
Wazuh API | 55000 | TCP | RESTful API |
OpenSearch | 9200 | TCP | REST API |
OpenSearch | 9300 | TCP | Transport (cluster) |
OpenSearch Dashboards | 5601 | TCP | Web interface |
Filebeat | - | - | Outbound to OpenSearch |
Installation Steps
Step 1: System Preparation
# Update system packagessudo apt update && sudo apt upgrade -y
# Install required dependenciessudo apt install -y curl wget gnupg2 software-properties-common apt-transport-https ca-certificates
# Set system limits for OpenSearchecho "* soft nofile 65536" | sudo tee -a /etc/security/limits.confecho "* hard nofile 65536" | sudo tee -a /etc/security/limits.confecho "* soft memlock unlimited" | sudo tee -a /etc/security/limits.confecho "* hard memlock unlimited" | sudo tee -a /etc/security/limits.conf
# Configure kernel parametersecho "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.confsudo sysctl -p
Step 2: Install Java (Required for OpenSearch)
# Install OpenJDK 11sudo apt install -y openjdk-11-jdk
# Set JAVA_HOMEecho 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64' | sudo tee -a /etc/environmentsource /etc/environment
# Verify installationjava -version
Step 3: Install OpenSearch
# Add OpenSearch repositorycurl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | sudo gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyringecho "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" | sudo tee /etc/apt/sources.list.d/opensearch-2.x.list
# Update package list and installsudo apt updatesudo apt install -y opensearch=2.19.2
# Configure OpenSearchsudo cp opensearch.yml /etc/opensearch/opensearch.yml
# Enable and start servicesudo systemctl daemon-reloadsudo systemctl enable opensearchsudo systemctl start opensearch
# Verify installationcurl -X GET "localhost:9200" -u admin:admin --insecure
Step 4: Install OpenSearch Dashboards
# Install OpenSearch Dashboardssudo apt install -y opensearch-dashboards=2.19.2
# Configure OpenSearch Dashboardssudo cp opensearch_dashboards.yml /etc/opensearch-dashboards/opensearch_dashboards.yml
# Enable and start servicesudo systemctl enable opensearch-dashboardssudo systemctl start opensearch-dashboards
# Access web interface# https://localhost:5601 (admin/admin)
Step 5: Install Wazuh Manager
# Add Wazuh repositorycurl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | sudo gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --importsudo chmod 644 /usr/share/keyrings/wazuh.gpgecho "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | sudo tee -a /etc/apt/sources.list.d/wazuh.list
# Install Wazuh Managersudo apt updatesudo apt install -y wazuh-manager=4.12.0-*
# Enable and start servicesudo systemctl enable wazuh-managersudo systemctl start wazuh-manager
# Verify installationsudo systemctl status wazuh-manager
Step 6: Install and Configure Filebeat
# Add Elastic repositorywget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
# Install Filebeatsudo apt updatesudo apt install -y filebeat=7.10.2
# Download Wazuh Filebeat modulecurl -s https://packages.wazuh.com/4.x/filebeat/wazuh-filebeat-0.2.tar.gz | sudo tar -xvz -C /usr/share/filebeat/module
# Configure Filebeat for OpenSearchsudo cp filebeat_opensearch_config.yml /etc/filebeat/filebeat.yml
# Download Wazuh template for OpenSearchsudo curl -so /etc/filebeat/wazuh-template.json https://raw.githubusercontent.com/wazuh/wazuh/v4.12.0/extensions/elasticsearch/7.x/wazuh-template.json
# Configure authenticationecho 'OPENSEARCH_USERNAME=admin' | sudo tee -a /etc/default/filebeatecho 'OPENSEARCH_PASSWORD=admin' | sudo tee -a /etc/default/filebeat
# Enable and start Filebeatsudo systemctl enable filebeatsudo systemctl start filebeat
# Test Filebeat connectionsudo filebeat test output
Configuration
Wazuh Manager Configuration
Edit /var/ossec/etc/ossec.conf
:
<ossec_config> <global> <jsonout_output>yes</jsonout_output> <alerts_log>yes</alerts_log> <logall>no</logall> <logall_json>no</logall_json> </global>
<alerts> <log_alert_level>3</log_alert_level> <email_alert_level>12</email_alert_level> </alerts>
<!-- Enable vulnerability detection --> <vulnerability-detection> <enabled>yes</enabled> <index-status>yes</index-status> <feed-update-interval>60m</feed-update-interval> </vulnerability-detection>
<!-- Configure indexer connection --> <indexer> <enabled>yes</enabled> <hosts> <host>https://127.0.0.1:9200</host> </hosts> <ssl> <certificate_authorities> <ca>/etc/filebeat/certs/root-ca.pem</ca> </certificate_authorities> <certificate>/etc/filebeat/certs/filebeat.pem</certificate> <key>/etc/filebeat/certs/filebeat-key.pem</key> </ssl> </indexer></ossec_config>
SSL Certificate Generation
# Create certificate directorysudo mkdir -p /etc/filebeat/certs
# Generate certificates using the provided scriptsudo ./generate_certificates.sh
# Set proper permissionssudo chown -R root:root /etc/filebeat/certssudo chmod 600 /etc/filebeat/certs/*
Alert Correlation Implementation
Basic Correlation Rules
The correlation rules provide:
- Brute Force Detection: Multiple failed login attempts
- Successful Compromise: Login success after failed attempts
- Lateral Movement: Network activity after successful login
- Privilege Escalation: Critical file modifications
- Data Exfiltration: Suspicious data transfer activities
- Multi-stage Attacks: Advanced persistent threat detection
Implementation Steps
# Copy correlation rulessudo cp custom_correlation_rules.xml /var/ossec/etc/rules/local_rules.xml
# Set proper ownershipsudo chown root:ossec /var/ossec/etc/rules/local_rules.xmlsudo chmod 640 /var/ossec/etc/rules/local_rules.xml
# Restart Wazuh manager to load new rulessudo systemctl restart wazuh-manager
# Verify rules are loadedsudo /var/ossec/bin/ossec-logtest < test_log.txt
Custom Correlation Example
Create advanced correlation for detecting credential stuffing:
<!-- Detect multiple failed logins from different IPs for same user --><rule id="100100" level="8" frequency="5" timeframe="600"> <if_matched_sid>5710</if_matched_sid> <same_user /> <description>Multiple failed login attempts for same user from different IPs</description> <group>credential_stuffing,authentication_failures</group> <mitre> <id>T1110.004</id> </mitre></rule>
<!-- Detect successful login after credential stuffing --><rule id="100101" level="12" timeframe="1800"> <if_matched_sid>100100</if_matched_sid> <if_sid>5715</if_sid> <same_user /> <description>Successful login after credential stuffing attempts</description> <group>credential_stuffing_success</group> <mitre> <id>T1110.004</id> <id>T1078</id> </mitre></rule>
Dashboard Creation
OpenSearch Index Pattern Setup
# Use the dashboard manager scriptpython3 dashboard_manager.py \ --url https://localhost:9200 \ --username admin \ --password admin \ --action create-pattern \ --pattern-name "wazuh-alerts-*"
Custom Visualizations
-
Security Overview Dashboard
- Alert trends over time
- Top attack sources
- MITRE ATT&CK mapping
- Agent status overview
-
Correlation Analysis Dashboard
- Multi-stage attack timelines
- User behavior analytics
- Network traffic patterns
- File integrity monitoring
-
Compliance Dashboard
- PCI DSS compliance status
- GDPR data protection events
- HIPAA security incidents
- NIST framework coverage
Creating Custom Searches
{ "query": { "bool": { "must": [ { "range": { "rule.level": { "gte": 7 } } }, { "terms": { "rule.groups": ["attack", "authentication_failures"] } } ], "filter": [ { "range": { "timestamp": { "gte": "now-24h" } } } ] } }}
Troubleshooting
Common Issues and Solutions
1. Filebeat Connection Issues
# Check Filebeat logssudo journalctl -u filebeat -f
# Test connectionsudo filebeat test output
# Common fixes:# - Verify SSL certificates# - Check OpenSearch credentials# - Ensure proper file permissions
2. OpenSearch Memory Issues
# Increase heap size in /etc/opensearch/jvm.options-Xms4g-Xmx4g
# Monitor memory usagecurl -X GET "localhost:9200/_nodes/stats/jvm?pretty" -u admin:admin --insecure
3. Wazuh Rule Loading Issues
# Check rule syntaxsudo /var/ossec/bin/ossec-logtest
# Verify rule loadingsudo tail -f /var/ossec/logs/ossec.log
# Test specific rulesecho "test log message" | sudo /var/ossec/bin/ossec-logtest
4. Dashboard Loading Issues
# Check OpenSearch Dashboards logssudo journalctl -u opensearch-dashboards -f
# Verify index patternscurl -X GET "localhost:9200/_cat/indices/wazuh-*?v" -u admin:admin --insecure
# Clear browser cache and cookies
Performance Optimization
OpenSearch Optimization
cluster.routing.allocation.disk.threshold.enabled: truecluster.routing.allocation.disk.watermark.low: 85%cluster.routing.allocation.disk.watermark.high: 90%
# Index settingsindices.fielddata.cache.size: 40%indices.breaker.fielddata.limit: 60%indices.breaker.request.limit: 40%indices.breaker.total.limit: 70%
Wazuh Manager Optimization
<global> <max_agents>5000</max_agents> <white_list>127.0.0.1</white_list> <white_list>localhost</white_list></global>
<alerts> <log_alert_level>5</log_alert_level> <email_alert_level>12</email_alert_level></alerts>
Filebeat Optimization
queue.mem: events: 8192 flush.min_events: 1024 flush.timeout: 5s
output.elasticsearch: worker: 2 bulk_max_size: 2048 template.settings: index.refresh_interval: 10s
Security Considerations
SSL/TLS Configuration
Ensure all communications are encrypted:
- Wazuh Manager ↔ Agents
- Filebeat ↔ OpenSearch
- OpenSearch ↔ OpenSearch Dashboards
- Client ↔ OpenSearch Dashboards
Access Control
# Create restricted user for Filebeatcurl -X POST "localhost:9200/_plugins/_security/api/internalusers/filebeat" \ -u admin:admin --insecure \ -H 'Content-Type: application/json' \ -d '{ "password": "SecurePassword123!", "roles": ["filebeat_writer"] }'
Network Security
- Configure firewall rules
- Use VPNs for remote agents
- Implement network segmentation
- Monitor for suspicious network activity
Monitoring and Maintenance
Health Checks
#!/bin/bashecho "=== Wazuh Manager Status ==="sudo systemctl status wazuh-manager
echo "=== OpenSearch Status ==="curl -X GET "localhost:9200/_cluster/health?pretty" -u admin:admin --insecure
echo "=== Filebeat Status ==="sudo systemctl status filebeat
echo "=== Agent Status ==="sudo /var/ossec/bin/agent_control -l
Log Rotation
# Configure logrotate for Wazuh logssudo cat > /etc/logrotate.d/wazuh << EOF/var/ossec/logs/alerts/alerts.log { daily rotate 30 compress delaycompress missingok notifempty postrotate /bin/kill -HUP `cat /var/ossec/var/run/ossec-logd*.pid 2> /dev/null` 2> /dev/null || true endscript}EOF
Conclusion
This comprehensive setup provides:
- Real-time security monitoring
- Advanced threat correlation
- Rich visualization capabilities
- Scalable architecture
- Compliance reporting
- Performance optimization
For additional support, refer to:
Wazuh 4.12.0 + OpenSearch 2.19.2 + Filebeat Integration Guide
https://mranv.pages.dev/posts/wazuh-correlation-opensearch-implementation/