1. Enriching #
Adding context.
Enrichment filters #
filter {
translate {
source => "[http][response][status_code]"
target => "[http][response][status_label]"
dictionary => { "200" => "ok" "404" => "introuvable" "500" => "erreur serveur" }
fallback => "autre"
}
geoip { source => "[source][ip]" target => "[source]" }
elasticsearch {
hosts => ["https://es:9200"]
index => "referentiel-serveurs"
query => "host.name:%{[host][name]}"
fields => { "equipe" => "[labels][equipe]" }
}
}| Filter | Source | Watch out |
|---|---|---|
| translate | inline dictionary or file (reloaded) | ideal for small tables |
| geoip | GeoLite2 databases downloaded automatically | offline: provide the database with database |
| elasticsearch | one query per event | costly: keep for low volumes |
| jdbc_static / jdbc_streaming | relational database | jdbc_static caches locally |
2. Kafka #
Decoupling collection.
Consuming a topic #
input {
kafka {
bootstrap_servers => "kafka-1:9092,kafka-2:9092"
topics => ["logs-web"]
group_id => "logstash-web"
consumer_threads => 3 # au plus le nombre de partitions
codec => json
}
}Kafka absorbs spikes and Logstash or Elasticsearch downtime: collectors keep writing and Logstash catches up. Several Logstash instances with the same group_id share the partitions.
3. Testing pipelines #
Before production.
Checking syntax and behaviour #
bin/logstash -f web.conf --config.test_and_exit # syntaxe
bin/logstash -f web.conf --config.reload.automatic # rechargement à chaud en développement
echo '127.0.0.1 - - [09/Nov/2026:10:00:00 +0100] "GET / HTTP/1.1" 200 512' | bin/logstash -f web.confGood practice: Keep real log lines as test fixtures and astdout { codec => rubydebug }output in development; watch the_grokparsefailureand_dissectfailuretags in production.
4. Monitoring #
API and Stack Monitoring.
Sources #
- The monitoring API (port 9600):
_node/stats,_node/stats/pipelines,_node/hot_threads. - The Elastic Agent Logstash integration feeds Stack Monitoring in Kibana (throughput, latency, queue, JVM); the legacy internal
xpack.monitoringcollection is deprecated. - Centralised pipeline management from Kibana exists, depending on the licence.
Depending on the version: internal monitoring collection is deprecated since 8.x; prefer Elastic Agent and the Logstash integration.
5. Logstash on Kubernetes #
With ECK.
The Logstash resource #
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: logstash
spec:
count: 2
version: 9.1.0
elasticsearchRefs:
- name: elasticsearch
clusterName: prod
pipelines:
- pipeline.id: main
config.string: |
input { beats { port => 5044 } }
output {
elasticsearch {
hosts => [ "${PROD_ES_HOSTS}" ]
user => "${PROD_ES_USER}"
password => "${PROD_ES_PASSWORD}"
ssl_certificate_authorities => "${PROD_ES_SSL_CERTIFICATE_AUTHORITY}"
}
}
services:
- name: beats
service:
spec:
type: ClusterIP
ports: [{ port: 5044, name: beats, protocol: TCP, targetPort: 5044 }]Good to know: ECK injects the referenced cluster address, user and certificate as variables (PROD_ES_*forclusterName: prod) and creates a persistent volume for data (PQ, DLQ).
6. Logstash or ingest pipeline? #
Choosing where to transform.
Comparison #
| Criterion | Logstash | Ingest pipeline |
|---|---|---|
| Sources | very many (Kafka, JDBC, S3, syslog…) | whatever reaches Elasticsearch |
| Outputs | multiple (Elasticsearch, S3, Kafka…) | Elasticsearch |
| Operations | one more service to operate | built into the cluster |
| Typical case | routing, multiple destinations, buffering | Elastic Agent integrations, simple parsing |
