What you will learn in this TP
- Install Logstash
- Build a pipeline
- use the file input
- Combine different filters
- use the file output
- use conditions
- use variables
Introduction #
What you will learn in this section
- Install Logstash
- Build a pipeline
- use the file input
- Combine different filters
- use the file output
- use conditions
- use variables
This lab aims to teach you how to build a simple pipeline that will read a log file, process it and write its output to a new file
Prerequisites #
You must have a Linux machine with Logstash installed. If you do not have a machine or test environment, we invite you to do the lab on installing Logstash. For those doing the lab on the test environment, you can ask Vagrant to install Logstash:export DEPLOY_LOGSTASH=true; vagrant upInputs configuration #
You must create a file in /etc/logstash/conf.d named "0-input-file-nginx-access.conf".WARNING: In this lab, we specified the configuration file name (0-input-file-nginx-access.conf) but in a company, you will have to build your own naming standard that fits your context.
Reading a file
In this file, you must add the logstash configuration to read the contents of the file "/var/log/rousseltm/nginx-access.log". If you use our Vagrant test environment, the log files will already be present on the VM in the /var/log/rousseltm folder. Otherwise, you will have to copy them manually:
Filters configuration #
You must create a second file named "100-filter-nginx-access.conf".
Data extraction
You must identify the most suitable filter for a flat file and put the configuration that will extract the fields from the previously read log file knowing that this file has a single log format
Type modification
We want to convert the "http_code" field to an integer. Indeed, there are often arithmetic operations on this field when making restitutions (dashboard, alerts...). For example, display all codes between 200 and 205.
Date adaptation
As you noticed in the provided log file, the logs are not sorted. If you do not adapt the '@timestamp' field, you will have logs sorted by appearance in the file instead of sorting by generation date of the log line.
Field deletion
We want to remove the fields- event.original
- message: as we have already extracted the information that interests us
WARNING: This is a good practice to save storage space and performance.
In other labs, we will see that 'message' should only be removed in cases where we have no filter errors.
Outputs configuration #
You must create a file in /etc/logstash/conf.d named "200-output-file-nginx-access.conf".
Writing to a file
In this file, you must add the logstash configuration so that it writes our processed log to the file "/var/log/rousseltm/parsed/TYPE.json"
Difficulty level : ●●○○○ (2/5)
My progress
Sign in to track your progress and take notes. Sign in
Course Glossary
Logstash
An open-source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to...
Recommended Articles
Vector : les transforms en détail (remap et VRL, route, filter, réduction et métriques)
Transformer les événements dans Vector : remap et le langage VRL (analyse, enrichissement, gestio...
Vector : les sinks en détail (destinations, lots, tampons et réessais)
Envoyer les événements de Vector : sinks Loki, Elasticsearch, S3, Kafka, OpenTelemetry, Prometheu...
Grafana Alloy : Collecte et Transformation de Télémétrie
Apprenez à utiliser Grafana Alloy pour collecter, transformer et acheminer logs, métriques et tra...
CI/CD de bout en bout (1/5) : principes et anatomie d'un pipeline
Comprendre la CI/CD de bout en bout : intégration continue, livraison continue et déploiement con...
Collecteurs de logs légers : Fluent Bit, Vector et les autres
Pourquoi un collecteur de logs, ce qui distingue les agents légers (Fluent Bit, Vector) des colle...
OpenTelemetry Collector : les Processors (transformer, filtrer et protéger la télémétrie)
Maîtriser les processors du Collector OpenTelemetry : batch, memory_limiter, attributes, resource...
Bindplane : gérer ses pipelines de télémétrie OpenTelemetry
Comprendre Bindplane : plan de contrôle des collecteurs OpenTelemetry via OpAMP, BDOT Collector, ...
OpenTelemetry Collector, Grafana Alloy et Bindplane : comparer trois approches des pipelines de télémétrie
Comparatif détaillé de trois façons de gérer des pipelines de télémétrie : l'OpenTelemetry Collec...
Bonnes pratiques Bindplane
Check-list pour exploiter Bindplane : organisation par labels et fleets, réduction mesurée, masqu...