RousselTMLEARNING

Observability

Beats: going further (security, performance, Elastic Agent and migrating to Alloy)

Industrialize Filebeat, Metricbeat and the other Beats: secure outputs, processors, modules, tuning, monitoring, Elastic Agent and Fleet, and migrating to Grafana Alloy or OpenTelemetry.

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: true
filebeat 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-pager
Common 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 #

ParameterEffectAdvice
bulk_max_sizeSize of the batches sent1,000 – 4,000 depending on event size
workerParallel connections per hostIncrease if Elasticsearch can absorb it
queue.mem.eventsMemory bufferAdjust to the throughput
close_inactiveClosing inactive filesAvoids keeping thousands of files open
harvester_limitNumber of simultaneous readersLimit 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-xpack

3. Elastic Agent and Fleet #

The unified agent.

Principle #

Evolution paths from the Beats
Choose according to your backend and your multi-signal strategy.

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 inspect

4. Migrating to Alloy or OpenTelemetry #

Standardizing collection.

Equivalents and conversion #

BeatAlloy equivalentOTel Collector equivalent
Filebeatloki.source.file, loki.source.journalfilelogreceiver, journaldreceiver
Metricbeat (system)prometheus.exporter.unixhostmetricsreceiver
Packetbeat / Heartbeatprometheus.exporter.blackboxhttpcheckreceiver
Processorsloki.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.

Related articles

Beats: Filebeat, Metricbeat, Winlogbeat and their configuration

Written version of the video lessons: role of each Beat, configuration structure, inputs, modules, processors…

Other log sources and queues: syslog, Fluent Bit, Kafka, Redis

Written version of the video lessons: collect syslog, Fluent Bit and other sources, then insert a queue (Kafk…

Beats best practices: Filebeat, Metricbeat and reliable collection

Beats best practices: filestream, modules, processors, disk queues, secure outputs, ILM and templates, resour…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!