# Security Monitoring Stack (SIEM)

> Wazuh SIEM with Elasticsearch for log analysis, threat detection, and compliance monitoring

- Category: Security & Networking
- Difficulty: advanced
- Components: wazuh-manager, wazuh-indexer, wazuh-dashboard, filebeat
- Tags: wazuh, siem, security, elasticsearch, threat-detection, compliance
- Source: https://docker.recipes/security/security-siem-stack

## Overview

Wazuh is an open-source security monitoring platform that evolved from OSSEC, providing comprehensive threat detection, incident response, and compliance monitoring capabilities. The Wazuh manager serves as the central component that collects, analyzes, and correlates security events from agents deployed across your infrastructure, while also performing vulnerability assessments, configuration assessments, and file integrity monitoring. This stack combines the Wazuh manager with Wazuh indexer (based on OpenSearch) for scalable log storage and analysis, plus the Wazuh dashboard for visualization and management of security events, creating a complete SIEM solution. The integration enables real-time threat detection through rule-based analysis, machine learning algorithms, and threat intelligence feeds, while automatically correlating events across multiple sources to identify complex attack patterns. This configuration is ideal for security teams, compliance officers, and system administrators who need enterprise-grade security monitoring without the licensing costs of commercial SIEM solutions, offering capabilities comparable to tools like Splunk or QRadar while maintaining full control over sensitive security data.

## Features

- Real-time log analysis and correlation using Wazuh's rule engine with over 3,000 pre-built detection rules
- Host-based intrusion detection with rootkit detection, file integrity monitoring, and system call analysis
- Vulnerability assessment scanning with integration to CVE databases and OVAL definitions
- Compliance monitoring for PCI DSS, GDPR, HIPAA, NIST 800-53, and SOC 2 frameworks
- Active response capabilities allowing automated threat mitigation through custom scripts
- Threat intelligence integration with feeds from VirusTotal, AlienVault OTX, and custom IoC sources
- OpenSearch-based indexing providing fast search capabilities across terabytes of security logs
- Multi-tenant architecture supporting agent groups and role-based access control

## Use cases

- Security operations center (SOC) deployment for centralized threat monitoring and incident response
- Compliance auditing and reporting for organizations requiring regulatory adherence documentation
- Cloud security monitoring for AWS, Azure, and GCP environments with API-based log collection
- Network security monitoring through integration with firewalls, IDS/IPS, and network devices
- Endpoint detection and response (EDR) for workstations and servers across hybrid infrastructures
- DevSecOps integration providing security monitoring for containerized applications and CI/CD pipelines
- Managed security service provider (MSSP) deployments supporting multiple client environments

## Prerequisites

- Minimum 8GB RAM allocated to Docker (4GB for indexer, 2GB for manager, 2GB for dashboard)
- At least 50GB available disk space for log storage and indexer data retention
- Ports 1514/TCP, 1515/TCP, 514/UDP, 55000/TCP, and 5601/TCP available for agent communication and web access
- Basic understanding of security event analysis, log parsing, and SIEM concepts
- Network connectivity from monitored hosts to the Wazuh manager for agent enrollment and communication
- SSL certificate management knowledge for production deployments requiring encrypted communication

## docker-compose.yml

```yaml
services:
  wazuh-indexer:
    image: wazuh/wazuh-indexer:latest
    container_name: wazuh-indexer
    restart: unless-stopped
    environment:
      - "OPENSEARCH_JAVA_OPTS=-Xms1g -Xmx1g"
      - "bootstrap.memory_lock=true"
      - "discovery.type=single-node"
      - "plugins.security.ssl.http.enabled=false"
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    volumes:
      - wazuh_indexer_data:/var/lib/wazuh-indexer

  wazuh-manager:
    image: wazuh/wazuh-manager:latest
    container_name: wazuh-manager
    restart: unless-stopped
    ports:
      - "1514:1514"
      - "1515:1515"
      - "514:514/udp"
      - "55000:55000"
    environment:
      - INDEXER_URL=https://wazuh-indexer:9200
      - INDEXER_USERNAME=admin
      - INDEXER_PASSWORD=${INDEXER_PASSWORD}
      - FILEBEAT_SSL_VERIFICATION_MODE=none
    volumes:
      - wazuh_api_config:/var/ossec/api/configuration
      - wazuh_etc:/var/ossec/etc
      - wazuh_logs:/var/ossec/logs
      - wazuh_queue:/var/ossec/queue
      - wazuh_var_multigroups:/var/ossec/var/multigroups
      - wazuh_integrations:/var/ossec/integrations
      - wazuh_active_response:/var/ossec/active-response/bin
      - wazuh_agentless:/var/ossec/agentless
      - wazuh_wodles:/var/ossec/wodles
      - filebeat_etc:/etc/filebeat
      - filebeat_var:/var/lib/filebeat
    depends_on:
      - wazuh-indexer

  wazuh-dashboard:
    image: wazuh/wazuh-dashboard:latest
    container_name: wazuh-dashboard
    restart: unless-stopped
    ports:
      - "${DASHBOARD_PORT:-5601}:5601"
    environment:
      - INDEXER_USERNAME=admin
      - INDEXER_PASSWORD=${INDEXER_PASSWORD}
      - WAZUH_API_URL=https://wazuh-manager
      - DASHBOARD_USERNAME=kibanaserver
      - DASHBOARD_PASSWORD=${DASHBOARD_PASSWORD}
      - API_USERNAME=wazuh-wui
      - API_PASSWORD=${API_PASSWORD}
    depends_on:
      - wazuh-indexer
      - wazuh-manager

volumes:
  wazuh_indexer_data:
  wazuh_api_config:
  wazuh_etc:
  wazuh_logs:
  wazuh_queue:
  wazuh_var_multigroups:
  wazuh_integrations:
  wazuh_active_response:
  wazuh_agentless:
  wazuh_wodles:
  filebeat_etc:
  filebeat_var:
```

## .env

```bash
# Wazuh SIEM Stack
DASHBOARD_PORT=5601

# Passwords (change these!)
INDEXER_PASSWORD=SecretPassword
DASHBOARD_PASSWORD=SecretPassword
API_PASSWORD=SecretPassword
```

## Usage notes

- Wazuh Dashboard at http://localhost:5601
- Default login: admin / SecretPassword
- Install Wazuh agents on hosts to monitor
- Agents connect to port 1514 (TCP) or 1515 (TCP)
- Syslog collection on port 514 (UDP)
- API accessible at port 55000

## Troubleshooting

- Wazuh indexer failing to start with memory errors: Increase Docker memory allocation or reduce OPENSEARCH_JAVA_OPTS heap size from 1g to 512m
- Agents showing as disconnected in dashboard: Verify firewall rules allow connections to ports 1514/1515 and check agent configuration file for correct manager IP
- Dashboard login failing with authentication errors: Reset passwords using docker exec wazuh-manager /var/ossec/bin/wazuh-keystore and restart containers
- High CPU usage on wazuh-manager: Review active rules in /var/ossec/etc/rules and disable unnecessary decoders or reduce log verbosity
- Indexer running out of disk space: Configure index lifecycle policies in dashboard under Management > Index Management to automatically rotate old indices
- Missing security events in dashboard: Check filebeat configuration and verify log parsing by examining /var/ossec/logs/alerts/alerts.log for raw events

