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.
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/_startLatest #
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" } }
}| Mode | Behaviour |
|---|---|
| batch | one-off computation on existing data |
| continuous | with sync: regular updates according to frequency |
Good practice: Test withPOST _transform/_previewbefore creating, and followGET _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).| Type | Matching |
|---|---|
| match | exact value (ID, name) |
| range | range (IP address range) |
| geo_match | geographic 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 equipeDepending on the version:LOOKUP JOIN(join with a lookup-mode index) is available in recent versions (8.18 / 9.x);ENRICHrelies on the same enrich policies as ingest.
My progress
Sign in to track your progress and take notes. Sign in
💬 Recent discussions about this course
- Elasticsearch : supprimer automatiquement les logs de plus de 30 jours✓ solved · 1 reply(ies)
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...