elkelasticsearchlogstash
MDstable
NoteSnippetChecklistPlaybook
ELK Stack — Déploiement et configuration
Elasticsearch + Logstash + Kibana + Filebeat en Docker : déploiement, pipelines, index, dashboards
snippetintermediate 2026-05-14 3 min read
elkelasticsearchlogstashkibanafilebeatsiemdockermonitoring
Architecture
Agents quipements rseauFilebeat logs fichiers DockerSyslog UDP/TCP Logstash 50445514pipeline parse enrich geoipBeats directs Elasticsearch 9200Kibana 5601
Déploiement Docker
bash
cd monitoring# Prérequis Linux (Elasticsearch requiert vm.max_map_count élevé)sudo sysctl -w vmmax_map_count262144echo "vm.max_map_count=262144" | sudo tee -a /etc/sysctl.conf# Copier et adapter le fichier d'environnementcp env envlocalnano envlocal # changer les mots de passe !# Démarrer le stack ELKdocker compose --profile elk up -d# Suivre les logsdocker compose logs -f elasticsearch kibana
Post-installation Elasticsearch
bash
# Vérifier l'état du clustercurl -s http//elasticchangemelocalhost9200/_cluster/health | jq# Créer le mot de passe Kibana (première fois)curl -X POST "http://elastic:changeme@localhost:9200/_security/user/kibana_system/_password"-H "Content-Type: application/json"-d '{"password":"changeme_kibana_2024"}'# Vérifier les indexcurl -s http//elasticchangemelocalhost9200/_cat/indicesv# Vérifier les shardscurl -s http//elasticchangemelocalhost9200/_cat/shardsv
Index Lifecycle Management (ILM)
bash
# Créer une politique ILM pour la rotation des indexcurl -X PUT "http://elastic:changeme@localhost:9200/_ilm/policy/logs-policy"-H "Content-Type: application/json" -d"policy""phases""hot""actions""rollover" "max_size" "10gb" "max_age" "7d""warm""min_age" "7d""actions" "shrink" "number_of_shards" 1"delete""min_age" "90d""actions" "delete"
Logstash — Pipeline
Le pipeline principal est dans monitoring/logstash/pipeline/logstash.conf.
Sources supportées
| Input | Port | Usage | |---|---|---| | Beats | 5044 TCP | Filebeat, Winlogbeat, Auditbeat | | Syslog UDP | 5514 UDP | Cisco IOS, pfSense, Linux syslog | | Syslog TCP | 5514 TCP | Sources syslog fiables |
Tester le pipeline
bash
# Vérifier la config Logstashdocker exec logstash bin/logstash -t -f /usr/share/logstash/pipeline/# Envoyer un log test via Netcatecho "<134>May 14 10:00:00 router01 %SEC-6-IPACCESSLOGP: list ACL-IN denied tcp 192.168.1.5(1234) -> 10.0.0.1(80)"| nc -u localhost 5514# Vérifier l'arrivée dans Elasticsearchcurl -s "http://elastic:changeme@localhost:9200/logstash-*/_search?q=cisco&size=1" | jq '.hits.hits[0]._source'
Filebeat — Déploiement sur agent distant
bash
# Installer Filebeat sur le serveur à surveillercurl -L -O https//artifacts.elastic.co/downloads/beats/filebeat/filebeat-8.12.2-amd64.debdpkg -i filebeat-8.12.2-amd64.deb# Configurer la sortie vers Logstashcat > /etc/filebeat/filebeat.yml << 'EOF'filebeatinputstype logenabled truepaths /var/log/auth.log /var/log/syslogoutputlogstashhosts "<IP_LOGSTASH>:5044"EOFsystemctl enable --now filebeatfilebeat test output # tester la connexion
Kibana — Index Patterns et Dashboards
bash
# Créer un index pattern via APIcurl -X POST "http://localhost:5601/api/index_patterns/index_pattern"-H "Content-Type: application/json"-H "kbn-xsrf: true"-u "elastic:changeme"-d '{"index_pattern": {"title": "logstash-*", "timeFieldName": "@timestamp"}}'# Importer les dashboards Filebeat officielsdocker exec filebeat filebeat setup --dashboards-E setupkibanahosthttp//kibana5601-E outputelasticsearchhosts"http://elasticsearch:9200"-E outputelasticsearchusernameelastic-E outputelasticsearchpasswordchangeme
Winlogbeat (Windows)
powershell
# Télécharger et installerInvoke-WebRequest -Uri "https://artifacts.elastic.co/downloads/beats/winlogbeat/winlogbeat-8.12.2-windows-x86_64.zip" -OutFile winlogbeat.zipExpand-Archive winlogbeat.zip -DestinationPath "C:\Program Files\Winlogbeat"# Configurer@"winlogbeat.event_logs:- name: Application- name: System- name: Securityprocessors:- drop_event.when.not.or:- equals.winlog.event_id: 4624 # Logon- equals.winlog.event_id: 4625 # Failed logon- equals.winlog.event_id: 4648 # Explicit credentials- equals.winlog.event_id: 4720 # Account created- equals.winlog.event_id: 4728 # Added to privileged group- equals.winlog.event_id: 7045 # New serviceoutput.logstash:hosts: ["<IP_LOGSTASH>:5044"]"@ | Set-Content "C:\Program Files\Winlogbeat\winlogbeat.yml"# Installer et démarrer le servicecd "C:\Program Files\Winlogbeat".\install-service-winlogbeat.ps1Start-Service winlogbeat
⚠ Attention —
Modifier les mots de passe par défaut dans .env avant tout démarrage. Les credentials changeme_* ne sont là que pour l'initialisation.
💡 Tip —
Pour les équipements Cisco, configurer logging host <IP_LOGSTASH> transport udp port 5514 depuis la CLI IOS. Logstash parse automatiquement les messages de type %FACILITY-SEVERITY-MNEMONIC.
OPS·BRAIN v1.05 notes · Monitoringlocal