RousselTMLEARNING

Observability

Elasticsearch ingestion: Bulk API, ingest pipelines, enrich and reindex

Ingest and transform data in Elasticsearch: Bulk API, ingest pipelines and processors (grok, dissect, date, geoip, user_agent, script), simulate, error handling, enrich policies, reindex and the place of Logstash and Elastic Agent.

1. The Bulk API #

Indexing in bulk.

NDJSON format #

POST _bulk
{ "create": { "_index": "logs-nginx-default" } }
{ "@timestamp": "2026-10-20T10:00:00Z", "message": "203.0.113.5 - - [20/Oct/2026:10:00:00 +0000] \"GET /api/cart HTTP/1.1\" 200 512 \"-\" \"Mozilla/5.0\"" }
{ "create": { "_index": "logs-nginx-default" } }
{ "@timestamp": "2026-10-20T10:00:01Z", "message": "198.51.100.7 - - [20/Oct/2026:10:00:01 +0000] \"POST /api/order HTTP/1.1\" 500 87 \"-\" \"curl/8.5\"" }
Good practice: Aim for bulk requests of 5 to 15 MB and always check the response's errors field: a « successful » bulk may contain rejected documents.

2. Ingest pipelines #

Transforming at ingestion.

Nginx pipeline #

Processors of an Nginx ingest pipeline
PUT _ingest/pipeline/nginx-access
{
  "processors": [
    { "grok": { "field": "message", "patterns": [ "%{IPORHOST:source.ip} - %{DATA:user.name} \\[%{HTTPDATE:nginx.time}\\] \"%{WORD:http.request.method} %{DATA:url.path} HTTP/%{NUMBER:http.version}\" %{NUMBER:http.response.status_code:int} %{NUMBER:http.response.body.bytes:long} \"%{DATA:http.request.referrer}\" \"%{DATA:user_agent.original}\"" ] } },
    { "date":       { "field": "nginx.time", "formats": [ "dd/MMM/yyyy:HH:mm:ss Z" ] } },
    { "geoip":      { "field": "source.ip", "target_field": "source.geo", "ignore_missing": true } },
    { "user_agent": { "field": "user_agent.original", "ignore_missing": true } },
    { "remove":     { "field": [ "nginx.time" ] } }
  ],
  "on_failure": [
    { "set": { "field": "event.kind", "value": "pipeline_error" } },
    { "set": { "field": "error.message", "value": "{{ _ingest.on_failure_message }}" } }
  ]
}

POST _ingest/pipeline/nginx-access/_simulate
{ "docs": [ { "_source": { "message": "203.0.113.5 - - [20/Oct/2026:10:00:00 +0000] \"GET /api/cart HTTP/1.1\" 200 512 \"-\" \"Mozilla/5.0\"" } } ] }
Good to know: dissect is faster than grok when the format is fixed (known separators); keep grok for variable formats.

3. Enrich and reindex #

Completing and reprocessing.

Enrich #

PUT _enrich/policy/customers
{ "match": { "indices": "customers", "match_field": "customer.id", "enrich_fields": [ "customer.tier", "customer.country" ] } }
POST _enrich/policy/customers/_execute

# dans un pipeline
{ "enrich": { "policy_name": "customers", "field": "customer.id", "target_field": "customer_info" } }

# retraiter un index existant avec un pipeline
POST _reindex
{ "source": { "index": "old-logs" }, "dest": { "index": "logs-nginx-default", "op_type": "create", "pipeline": "nginx-access" } }

Logstash and Elastic Agent remain useful when you need varied sources, buffers or multiple outputs; ingest pipelines are enough to transform what already arrives in Elasticsearch.

Related articles

Transforms and enrich: summarising and enriching data in Elasticsearch

Build entity-centric indices with pivot and latest transforms, and enrich documents at ingest time with enric…

OpenTelemetry and Elasticsearch: compatibility and architecture

Send OpenTelemetry to Elasticsearch: Collector and elasticsearch exporter, managed OTLP endpoint, APM Server,…

Ingesting OpenTelemetry logs into Elasticsearch

Collect and structure logs with the OpenTelemetry Collector (filelog receiver, operators, transform processor…

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!