The correction is integrated into the TP (See the green boxes)
What you will learn in this TP
- Create and simulate a pipeline
- Deploy Data Prepper
- Type fields correctly
Introduction #
What you will learn in this section
- Create and simulate a pipeline
- Deploy Data Prepper
- Type fields correctly
Context. Your logs arrive poorly structured. You normalize them first inside the cluster, then with a dedicated collector.
Prerequisites: the previous lab · Estimated time: 45 min
Clean, well-typed data.Setup #
Guided steps, with their solution.
1. Create and simulate a pipeline
Why?
Create the pipeline, then test it without indexing anything._simulateavoids damaging data.See the correction
curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' -X PUT https://localhost:9200/_ingest/pipeline/logs_nettoyage -d '{ "description": "Normalizes the level and extracts the user", "processors": [ {"lowercase": {"field": "level"}}, {"set": {"field": "environnement", "value": "prod"}}, {"grok": {"field": "message", "patterns": ["utilisateur=%{WORD:utilisateur}"], "ignore_failure": true}} ] }' # Try without indexing anything curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' -X POST https://localhost:9200/_ingest/pipeline/logs_nettoyage/_simulate \ -d '{"docs":[{"_source":{"level":"ERROR","message":"refus utilisateur=alice"}}]}'2. Apply it
Why? The pipeline is chosen at write time.
Reindex the batch of the previous lab with the pipeline, and find the document of useralice.See the correction
curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/x-ndjson' \ -X POST 'https://localhost:9200/_bulk?pipeline=logs_nettoyage&refresh=true' --data-binary @lot.ndjson curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' -X POST 'https://localhost:9200/logs-app-*/_search' -d '{"query":{"term":{"utilisateur.keyword":"alice"}}}'3. Prepare the typing
Why? Without a template,
Create theclientipwould be text and network search would fail.web-logstemplate.See the correction
curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' -X PUT https://localhost:9200/_index_template/web_logs -d '{ "index_patterns": ["web-logs*"], "template": { "settings": {"number_of_shards": 1, "number_of_replicas": 0}, "mappings": {"properties": { "@timestamp": {"type": "date"}, "clientip": {"type": "ip"}, "verb": {"type": "keyword"}, "request": {"type": "keyword"}, "response": {"type": "integer"}, "bytes": {"type": "integer"} }} } }'4. Deploy Data Prepper
Why? Processing leaves the cluster and relieves its nodes.
Writepipelines.yaml, add the service and start it.See the correction
log-pipeline: source: http: ssl: false port: 2021 path: /log/ingest processor: - grok: match: log: ['%{COMMONAPACHELOG}'] - date: match: - key: timestamp patterns: ["dd/MMM/yyyy:HH:mm:ss Z"] destination: "@timestamp" - convert_type: key: response type: integer - delete_entries: with_keys: ["log"] sink: - opensearch: hosts: ["https://opensearch:9200"] insecure: true username: admin password: "Str0ng!Passw0rd-2026" index: web-logs flush_timeout: 5000services: opensearch: image: opensearchproject/opensearch:3 environment: discovery.type: single-node OPENSEARCH_INITIAL_ADMIN_PASSWORD: ${OPENSEARCH_INITIAL_ADMIN_PASSWORD} OPENSEARCH_JAVA_OPTS: -Xms1g -Xmx1g path.repo: /usr/share/opensearch/data/snapshots ports: - "9200:9200" volumes: - os-data:/usr/share/opensearch/data dashboards: image: opensearchproject/opensearch-dashboards:3 environment: OPENSEARCH_HOSTS: '["https://opensearch:9200"]' ports: - "5601:5601" depends_on: [opensearch] data-prepper: image: opensearchproject/data-prepper:2 ports: - "2021:2021" volumes: - ./pipelines.yaml:/usr/share/data-prepper/pipelines/pipelines.yaml:ro depends_on: [opensearch] volumes: os-data:docker compose up -d5. Send and check
Why? Network search proves that the
Send two log lines, wait a few seconds, then search addresses iniptype is in place.10.0.0.0/8.See the correction
curl -s -X POST -H 'Content-Type: application/json' http://localhost:2021/log/ingest -d '[ {"log":"127.0.0.1 - frank [04/Nov/2026:10:00:00 +0100] \"GET /index.html HTTP/1.1\" 200 2326"}, {"log":"10.0.0.8 - alice [04/Nov/2026:10:00:01 +0100] \"GET /admin HTTP/1.1\" 403 120"} ]'sleep 10 curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' -X POST https://localhost:9200/web-logs/_search -d '{"query":{"term":{"clientip":"10.0.0.0/8"}}}' curl -sk -u 'admin:Str0ng!Passw0rd-2026' -H 'Content-Type: application/json' https://localhost:9200/web-logs/_mapping
Difficulty level : ●●○○○ (2/5)
My progress
Sign in to track your progress and take notes. Sign in
Recommended Articles
Feeding OpenSearch: ingest pipelines and Data Prepper
Transform data with ingest pipelines, collect with Data Prepper, receive OTLP and avoid the dynam...
Ingestion Elasticsearch : Bulk API, ingest pipelines, enrich et reindex
Ingérer et transformer des données dans Elasticsearch : Bulk API, ingest pipelines et processeurs...
OpenSearch: concepts, architecture and differences with Elasticsearch
Understanding OpenSearch: project origin, license, differences with Elasticsearch, indexes, shard...
Data streams et templates Elasticsearch : component templates, index templates et séries temporelles
Gérer les données horodatées avec les data streams : index templates et component templates, conv...
Index Lifecycle Management (ILM) : data tiers, rollover et rétention
Automatiser le cycle de vie des index avec ILM : data tiers hot, warm, cold et frozen, rollover p...
Les Data Sources dans Grafana : Connectez et unifiez vos données
Apprenez à étendre les capacités de Grafana via les Data Sources. Découvrez les plugins essentiel...
OpenSearch Dashboards, alerting and observability
Explore data in OpenSearch Dashboards, create alert monitors and discover Trace Analytics, Event ...
Logs Datadog avancés : index, filtres d'exclusion, Flex Logs, archives et Sensitive Data Scanner
Maîtriser coût et conformité des logs Datadog : pipelines et processeurs, index et rétention, fil...
Kibana avancé : data views, Lens, dashboards, alerting et reporting
Exploiter Kibana en profondeur : data views et champs runtime, Discover, Lens et formules, dashbo...