1. Securing and hardening the Beats #
Outputs and processors.
TLS output and queue #
# filebeat.yml
filebeat.inputs:
- type: filestream
id: app-logs
paths: [/var/log/app/*.log]
parsers: [{ ndjson: { target: "", add_error_key: true } }]
processors:
- add_host_metadata: ~
- add_docker_metadata: ~
- drop_event: { when: { equals: { log.level: debug } } }
- drop_fields: { fields: [agent.ephemeral_id, ecs.version] }
- script:
lang: javascript
source: |
function process(event) { var m = event.Get("message"); if (m && m.indexOf("password") >= 0) event.Cancel(); }
output.elasticsearch:
hosts: ["https://es01:9200"]
api_key: "${ES_API_KEY}"
ssl.certificate_authorities: ["/etc/filebeat/ca.crt"]
bulk_max_size: 2048
worker: 2
queue.disk: { max_size: 2GB } # file persistante : pas de perte si Elasticsearch est indisponible
logging.metrics.enabled: truefilebeat test config -e
filebeat test output
filebeat modules list | head
filebeat modules enable nginx system && filebeat setup --index-management
sudo systemctl restart filebeat && journalctl -u filebeat -n 50 --no-pagerCommon mistake: Never store passwords in plain text: use the keystore (filebeat keystore create && filebeat keystore add ES_API_KEY) and then${ES_API_KEY}.
2. Performance and monitoring #
Settings and metrics.
Tuning #
| Parameter | Effect | Advice |
|---|---|---|
bulk_max_size | Size of the batches sent | 1,000 – 4,000 depending on event size |
worker | Parallel connections per host | Increase if Elasticsearch can absorb it |
queue.mem.events | Memory buffer | Adjust to the throughput |
close_inactive | Closing inactive files | Avoids keeping thousands of files open |
harvester_limit | Number of simultaneous readers | Limit it on large directories |
# Métriques internes
curl -s localhost:5066/stats | jq '.libbeat.output.events'
filebeat -e -d "publish" # debug d'envoi
# Monitoring avec Metricbeat : metricbeat modules enable beat-xpack3. Elastic Agent and Fleet #
The unified agent.
Principle #
Elastic Agent combines the Beats into a single binary (logs, metrics, security) managed remotely by Fleet: centralized policies, one-click updates, preconfigured integrations in Kibana.
# Enrôler un agent Fleet
curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-8.15.0-linux-x86_64.tar.gz
tar xzf elastic-agent-*.tar.gz && cd elastic-agent-*
sudo ./elastic-agent install --url=https://fleet.exemple.fr:8220 --enrollment-token=<TOKEN>
sudo elastic-agent status
sudo elastic-agent inspect4. Migrating to Alloy or OpenTelemetry #
Standardizing collection.
Equivalents and conversion #
| Beat | Alloy equivalent | OTel Collector equivalent |
|---|---|---|
| Filebeat | loki.source.file, loki.source.journal | filelogreceiver, journaldreceiver |
| Metricbeat (system) | prometheus.exporter.unix | hostmetricsreceiver |
| Packetbeat / Heartbeat | prometheus.exporter.blackbox | httpcheckreceiver |
| Processors | loki.process, otelcol.processor.* | transform, filter, attributes |
// Équivalent Alloy d'un input Filebeat vers Elasticsearch/OTLP
local.file_match "app" { path_targets = [{"__path__" = "/var/log/app/*.log"}] }
loki.source.file "app" { targets = local.file_match.app.targets forward_to = [loki.write.default.receiver] }Good practice: Migrate progressively: run the old and new agents in parallel on a few hosts, compare volumes (count_over_time), then roll out widely.