AI‑driven strategies for NIS2 compliance in SMEs: monitoring, incident response, and automated reporting
Machine-translated from Italian. Read the original
Introduction
Small and medium-sized enterprises (SMEs) must adapt to the new NIS2 framework, which imposes obligations for risk management, continuous monitoring, incident notification within 24 hours, and periodic reporting. The use of Large Language Models (LLMs) and automation allows for reduced operational burden, improved detection speed, and guaranteed compliant reports.
Prerequisites
- Log infrastructure: servers, firewalls, endpoints, and applications must send logs to a centralized collector (e.g., Elastic, Loki, Splunk).
- LLM Model: a local model (e.g., Llama 2, Mistral) or a cloud service with prompt engineering capabilities for text analysis.
- Orchestration: automation tools (GitHub Actions, Azure Logic Apps, n8n) to execute playbooks.
- Knowledge of NIS2 requirements: consult the guide for SMEs on Penzai [1].
Proposed Architecture
[Log Sources] → Collector → Data Lake
│
├─> LLM (text analysis)
│
├─> SIEM/Alerting (Grafana, Prometheus)
│
└─> Reporting Engine → NIS2-compliant PDF/HTML
Step 1 – Log collection and normalization
- Configure devices (firewalls, servers, endpoints) to send logs in JSON or CEF format.
- Use Filebeat or Promtail to enrich logs with metadata (hostname, environment).
- Normalize with OpenTelemetry or Elastic Ingest Pipelines to ensure uniform schemas.
Step 2 – Log analysis with LLM
- Define prompts that ask the model to identify:
- Failed authentication events > 5 times in 10 min.
- Access from non-whitelisted IPs.
- Traffic anomalies (e.g., sudden outbound spikes).
- Run the prompt in batches (e.g., every 5 min) on new logs.
- Return a structured result (
{event_type, severity, description}) to be inserted into the SIEM.
FACT: LLMs can extract context from unstructured log messages, reducing false negatives (see HuggingFace blog on decision‑making with LLMs [2]).
Step 3 – Automated alerting
- Configure correlation rules in Grafana Alerting or Elastic Watcher based on LLM results.
- Send notifications via Slack, Teams, or ticketing (Jira Service Management).
- Set severity thresholds to trigger response playbooks.
Step 4 – LLM-guided incident response
- When an alert exceeds the threshold, the orchestrator starts a playbook:
- Endpoint isolation (
isolate‑host.sh). - Forensic collection (memdump, network logs).
- Endpoint isolation (
- The LLM generates a checklist of specific actions for the event type (e.g., phishing, ransomware).
- Actions are executed automatically or with manual approval, ensuring response times < 30 min.
Step 5 – Automated NIS2 report generation
- Aggregate monthly incidents into a dataset.
- The LLM fills out a mandatory template (description, impact, corrective measures, timelines).
- The result is exported to PDF/HTML and sent to the national CSIRT within the required 24 hours.
- Store reports in a versioned repository for audits.
Operational considerations
- Privacy: anonymize personal data before sending it to cloud LLMs (if used). Prefer on-premise models for sensitive data.
- Governance: define who can modify prompts and playbooks; version on Git.
- Validation: test prompts on historical datasets to measure false positive/negative rates.
References
- Penzai – NIS2 per le PMI: scadenze, obblighi e ruolo dei fornitori (https://penzai.it/it/blog/nis2-pmi-scadenze-obblighi-fornitori)
- Hugging Face – Decision‑making with LLMs (https://huggingface.co/blog/decision)
Questions for the community
- Which LLMs have you tried for log analysis and what results did you get?
- How do you handle the separation between sensitive data and automated analysis in GDPR-restricted environments?
- Have you already integrated automated response playbooks with open-source SIEMs? Share useful examples or patterns.