RousselTMLEARNING

Observability

Logstash: enrich, test, monitor and deploy on Kubernetes

Enrich with translate, geoip and elasticsearch, consume Kafka, test pipelines, monitor Logstash and deploy it on Kubernetes with ECK.

1. Enriching #

Adding context.

Enrichment filters #

Kafka input, dictionary, GeoIP and Elasticsearch lookup.
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]" }
  }
}
FilterSourceWatch out
translateinline dictionary or file (reloaded)ideal for small tables
geoipGeoLite2 databases downloaded automaticallyoffline: provide the database with database
elasticsearchone query per eventcostly: keep for low volumes
jdbc_static / jdbc_streamingrelational databasejdbc_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.conf
Good practice: Keep real log lines as test fixtures and a stdout { codec => rubydebug } output in development; watch the _grokparsefailure and _dissectfailure tags 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.monitoring collection 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_* for clusterName: prod) and creates a persistent volume for data (PQ, DLQ).

6. Logstash or ingest pipeline? #

Choosing where to transform.

Comparison #

CriterionLogstashIngest pipeline
Sourcesvery many (Kafka, JDBC, S3, syslog…)whatever reaches Elasticsearch
Outputsmultiple (Elasticsearch, S3, Kafka…)Elasticsearch
Operationsone more service to operatebuilt into the cluster
Typical caserouting, multiple destinations, bufferingElastic Agent integrations, simple parsing

Related articles

Logstash: role, pipeline concept and installation

Written version of the video lessons: what Logstash is for, how a pipeline works (inputs, filters, outputs, q…

Logstash: inputs and outputs

Written version of the video lessons: common inputs (beats, file, tcp/udp, http, kafka, jdbc) and outputs (el…

Logstash: filters, grok and dissect

Written version of the video lessons: essential filters (mutate, date, json, kv, drop), the grok plugin and i…

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!