Building a Local AI SOC Lab with Wazuh and Qwen: Lessons from a Real Implementation
Description and use
A local SOC lab with Wazuh and Qwen shows how an LLM can aid analysts while enforcing strict read‑only boundaries, yet relies on reliable data retrieval, state persistence, and safety filtering.
Problem
Can a locally hosted AI model help a security analyst investigate Wazuh alerts without giving the AI control over the infrastructure?
Outcome
The lab demonstrates that a locally hosted LLM can assist analysts with structured incident reports while maintaining strict read‑only boundaries, but requires reliable data retrieval, state persistence, and safety filtering.
Workflow
- Set up Ubuntu 24.04 VMs with Wazuh Agent, Manager, and OpenSearch; configure SSH port forwarding and TLS for secure access.
- Develop Python SOC Assistant to query OpenSearch using Scroll pagination and retrieve alerts.
- Store processed event IDs and incident reports in SQLite for reliable state and recovery.
- Connect LM Studio’s local API to Qwen 3.5‑4B Instruct and send selected events, requesting structured JSON output.
- Validate required fields in the model response before saving the report.
- Implement conservative recommendation filtering and regression tests to prevent unsafe actions.
- Run 31 mocked and offline Python tests via GitHub Actions to verify event identity, persistence, and read‑only boundaries.
- Manually execute the workflow and review AI-generated findings with a human analyst.
- Iterate on prompt design and safety measures based on testing results.
Evidence
I wanted to explore a practical question: Can a locally hosted AI model help a security analyst investigate Wazuh alerts without giving the AI control over the infrastructure?
I improved the Python client using OpenSearch Scroll pagination to retrieve a bounded snapshot of matching alerts.
During verification, I successfully migrated 20 existing event IDs and confirmed database integrity.
The application validates required fields before saving a report.
I introduced conservative recommendation filtering and regression tests to help keep responses within the lab's read-only investigation scope.
The repository includes 31 mocked and offline Python tests, exercised through GitHub Actions using Python 3.10 and 3.12.
- Record date: 2026-10-24T05:11:39.244Z