ELK + Wazuh — Intégration et règles de détection
Corréler les alertes Wazuh dans Kibana, règles Sigma, dashboards sécurité, alertes et cas d'usage SIEM
Stack complète
cd monitoringbash generate-certs.shdocker compose --profile all up -d
| Service | URL | Credentials |
|---|---|---|
| Kibana (ELK) | http://localhost:5601 | elastic / voir .env |
| Wazuh Dashboard | https://localhost:443 | admin / voir .env |
| Elasticsearch | http://localhost:9200 | elastic / voir .env |
| Wazuh API | https://localhost:55000 | wazuh-wui / voir .env |
Alimenter Elasticsearch avec les alertes Wazuh
Wazuh écrit ses alertes dans /var/ossec/logs/alerts/alerts.json. Filebeat les relaie vers Elasticsearch.
# Sur le host du manager, ajouter dans filebeat.yml :filebeatinputstype logpaths/var/lib/docker/volumes/wazuh-manager-data/_data/logs/alerts/alerts.jsonjsonkeys_under_root truejsonoverwrite_keys truetags "wazuh" "security"fieldslog_type wazuh-alertfields_under_root trueoutputelasticsearchhosts "http://localhost:9200"username elasticpassword "${ELASTIC_PASSWORD}"index "wazuh-alerts-%{+YYYY.MM.dd}"
Index Pattern Kibana pour alertes Wazuh
# Créer l'index pattern wazuh-alerts-*curl -X POST "http://localhost:5601/api/index_patterns/index_pattern"-H "Content-Type: application/json"-H "kbn-xsrf: true" -u elasticchangeme -d"index_pattern""title" "wazuh-alerts-*""timeFieldName" "timestamp"
Requêtes KQL — Kibana
# Alertes de niveau critique (>= 12)rulelevel > 12# Brute-force SSHruleid 5763 AND datasrcip# Modifications FIM (fichiers système)rulegroups syscheck AND full_log "/etc/*"# Connexions réussies avec compte privilégiéruleid 5501 AND datasrcuser root# Malware détectérulegroups rootcheck OR rulegroups virustotal# Alertes par agent spécifiqueagentname "srv-prod-01" AND rulelevel > 7# Timeline : toutes les alertes des 24 dernières heurestimestamp > now-24h AND rulelevel > 3
Elasticsearch — Requêtes directes
# Top 10 des règles les plus déclenchéescurl -s "http://elastic:changeme@localhost:9200/wazuh-alerts-*/_search"-H "Content-Type: application/json" -d"size" 0"aggs""top_rules""terms" "field" "rule.description.keyword" "size" 10' | jq 'aggregationstop_rulesbuckets# IPs sources les plus activescurl -s "http://elastic:changeme@localhost:9200/wazuh-alerts-*/_search"-H "Content-Type: application/json" -d"size" 0"query" "range" "timestamp" "gte" "now-24h""aggs""top_ips""terms" "field" "data.srcip.keyword" "size" 20' | jq 'aggregationstop_ipsbuckets# Alertes critiques (niveau >= 12)curl -s "http://elastic:changeme@localhost:9200/wazuh-alerts-*/_search"-H "Content-Type: application/json" -d"query""bool""must""range" "rule.level" "gte" 12"range" "timestamp" "gte" "now-1h""sort" "timestamp" "order" "desc""size" 20' | jq 'hitshits_source | timestamp agent_name agentname rule ruledescription level rulelevel
Alerting Kibana (Watcher / Rules)
# Créer une règle d'alerte sur brute-force SSHcurl -X POST "http://localhost:5601/api/alerting/rule"-H "Content-Type: application/json"-H "kbn-xsrf: true" -u elasticchangeme -d"name" "SSH Brute Force Alert""rule_type_id" ".es-query""schedule" "interval" "5m""params""index" "wazuh-alerts-*""timeField" "timestamp""timeWindowSize" 10"timeWindowUnit" "m""thresholdComparator" ">=""threshold" 5"esQuery" "{\"query\":{\"match\":{\"rule.id\":\"5763\"}}}""actions"
Cas d'usage SIEM — Détection
Détection brute-force SSH
Wazuh Rule IDs 5763 Multiple failed SSH 5551 sshdSeuil > 5 tentatives en 2 min depuis la mme IPActive Response firewall-drop blocageIndex KQL ruleid 5763
Détection de scan réseau
Wazuh Rule ID 40101 Nmap scan detectedLogstash parser les logs Snort/SuricataIndex KQL rulegroups ids AND dataaction DROP
Modification de fichiers système
Wazuh FIM Rule IDs 550 553 554Rpertoires surveills /etc /bin /usr/sbinKQL rulegroups syscheck AND full_log "/etc/passwd"Svrit 7 modification 12 suppression de fichier critique
Élévation de privilèges Linux
Wazuh Rule IDs 5902 sudo 5930 suKQL ruleid 5902 OR 5930 AND datadstuser root
Connexion depuis une IP géographiquement anormale
# Activer le module GeoIP dans Logstash (pipeline inclus)# Kibana Maps : visualiser les IPs sources par pays# Alerte : connexion SSH réussie depuis pays != FR
Dashboard recommandé — Kibana
Créer un dashboard "Security Overview" avec :
| Visualisation | Type | Champ |
|---|---|---|
| Alertes par niveau (aujourd'hui) | Bar chart | rule.level |
| Top 10 agents les plus alertés | Pie chart | agent.name |
| Carte GeoIP des IPs sources | Maps | geoip.location |
| Timeline des alertes critiques | Line chart | @timestamp (level≥12) |
| Dernières alertes critiques | Data table | rule.description, agent.name, timestamp |
| Statut des agents Wazuh | Metric | agent.status |
Créer un ILM index template pour les index wazuh-alerts-* : rétention 90 jours en hot, compression warm après 7 jours. Elasticsearch gère la rotation automatiquement et évite la saturation du disque.