RousselTMLEARNING

Article · Elasticsearch: from discovery to expertise

Transforms and enrich: summarising and enriching data

1. Transforms #

Pivot and latest.

Why #

Aggregations answer on the fly, but some questions are about entities: each customer's summary, each server's latest state. A transform computes that summary once, writes it to a destination index and keeps it up to date.

Source index, transform, destination index, dashboards.

Pivot #

PUT _transform/web-par-hote
{
  "source": { "index": "logs-nginx.access-*" },
  "dest":   { "index": "web-par-hote" },
  "pivot": {
    "group_by": {
      "hote":  { "terms": { "field": "host.name" } },
      "heure": { "date_histogram": { "field": "@timestamp", "calendar_interval": "1h" } }
    },
    "aggregations": {
      "requetes": { "value_count": { "field": "@timestamp" } },
      "octets":   { "sum": { "field": "http.response.body.bytes" } }
    }
  },
  "sync": { "time": { "field": "@timestamp", "delay": "60s" } },
  "frequency": "5m"
}
POST _transform/web-par-hote/_start

Latest #

PUT _transform/dernier-etat-hote
{
  "source": { "index": "metrics-system.cpu-*" },
  "dest":   { "index": "dernier-etat-hote" },
  "latest": { "unique_key": ["host.name"], "sort": "@timestamp" },
  "sync": { "time": { "field": "@timestamp" } }
}
ModeBehaviour
batchone-off computation on existing data
continuouswith sync: regular updates according to frequency
Good practice: Test with POST _transform/_preview before creating, and follow GET _transform/<id>/_stats: processed documents, failures, lag.

2. Enriching at ingest #

Enrich policies.

Policy and processor #

PUT _enrich/policy/serveurs
{ "match": { "indices": "referentiel-serveurs", "match_field": "host.name", "enrich_fields": ["equipe", "environnement"] } }
POST _enrich/policy/serveurs/_execute

PUT _ingest/pipeline/logs-nginx.access@custom
{ "processors": [ { "enrich": { "policy_name": "serveurs", "field": "host.name", "target_field": "serveur" } } ] }
Common mistake: Forgetting to re-execute the policy: the enrich index is a frozen copy of the reference data. After changing the reference data, run _execute again (for example nightly).
TypeMatching
matchexact value (ID, name)
rangerange (IP address range)
geo_matchgeographic shape

3. Enriching at query time #

ES|QL

ENRICH and LOOKUP JOIN #

FROM logs-nginx.access-*
| ENRICH serveurs ON host.name WITH equipe
| STATS erreurs = COUNT(*) BY equipe
Depending on the version: LOOKUP JOIN (join with a lookup-mode index) is available in recent versions (8.18 / 9.x); ENRICH relies on the same enrich policies as ingest.

📄 Transforms and enrich: summarising and enriching data in Elasticsearch →

My progress

  • ⏱ Estimated time : ≈ 6 min

Sign in to track your progress and take notes. Sign in

⭐ Rate this lesson

5.0 initial rating from the teaching team

Sign in to rate this lesson →

💬 Recent discussions about this course

Ask a question about this lesson →See all discussions about this course

Course Glossary

RBAC (Role-Based Access Control)

An access control method where permissions are assigned to specific roles (e.g., admin, reader) rather than directly to individual users.

Authentication

The process of verifying the identity of a user or system (e.g., login/password, tokens, biometrics).

Authorization

The process that occurs after authentication to determine if the entity has the necessary rights and privileges to access a resource.

API Key

A unique alphanumeric code used to identify, authenticate, and authorize access to an Application Programming Interface (API).

Architecture

The overall structural design of an IT system, defining its various components, their relationships, and the principles guiding its evolution.

Repository

A centralized storage location. This can refer to a source code repository (e.g., Git) or an artifact and binary repository (e.g., Harbor, Nexus, Arti...

Elasticsearch

A distributed, RESTful search and analytics engine capable of addressing a growing number of use cases, built on Apache Lucene.

Recommended Articles

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

Ingest and transform data in Elasticsearch: Bulk API, ingest pipelines and processors (grok, diss...

Logstash: enrich, test, monitor and deploy on Kubernetes

Enrich with translate, geoip and elasticsearch, consume Kafka, test pipelines, monitor Logstash a...

Index Lifecycle Management (ILM): data tiers, rollover and retention

Automate the index lifecycle with ILM: hot, warm, cold and frozen data tiers, rollover by size an...

Machine learning in Elastic: anomaly detection and AIOps

Automatically detect abnormal behaviour: anomaly detection jobs, datafeeds, detectors, influencer...

Elastic Security: SIEM, detection rules and investigation

Use Elastic Security as a SIEM: ECS data sources, detection rule types (query, EQL, ES|QL, thresh...

Elastic path project: centralising and using logs

The validation project of the "Elastic Stack mastery" path: Elastic Agent and Fleet, Logstash, El...

Elasticsearch data streams and templates: component templates, index templates and time series

Manage timestamped data with data streams: index templates and component templates, the type-data...

Logstash in production: persistent queues, DLQ and multiple pipelines

Make Logstash reliable in production: persistent queue, dead letter queue, multiple pipelines and...

Logstash: inputs and outputs

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

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!