RousselTMLEARNING

TP · Logstash: from discovery to expertise

My first pipeline

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
Mode :

All steps and instructions are shown. Recommended for this lab: guided

Introduction #

Context. nginx access logs are unreadable as they are. You build a first pipeline that reads them, extracts fields, fixes types and date, then writes them.

Prerequisites: a Linux machine with Logstash installed  ·  Estimated time: 45 min

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 up

Inputs 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.
  1. 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: .
    You must add a type for this file with the value 'nginx_access'.

Filters configuration #

You must create a second file named "100-filter-nginx-access.conf".

  1. 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

  2. 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.

  3. 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.

  4. Field deletion

    We want to remove the fields
    • event.original
    • message: as we have already extracted the information that interests us
    . Different methods must be used to remove them.
    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".

  1. 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"

Validate your work

Check that each goal above is reached and that you get the result described in the introduction.

Difficulty level : ●●○○○ (2/5)

My progress

  • ⏱ Estimated time : ≈ 45 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 →

💬 Questions about this lesson

No questions yet: be the first to ask for help or share your configuration.

Ask a question about this lesson →

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

Logstash: managing plugins and adopting Elastic Common Schema (ECS)

Written version of the video lessons: list, install, update and bundle Logstash plugins offline; ...

Logstash best practices: pipelines, performance, reliability and monitoring

Logstash best practices: multiple pipelines, dissect rather than grok, conditionals, persistent q...

Beats: going further (security, performance, Elastic Agent and migrating to Alloy)

Industrialize Filebeat, Metricbeat and the other Beats: secure outputs, processors, modules, tuni...

Logstash: role, pipeline concept and installation

Written version of the video lessons: what Logstash is for, how a pipeline works (inputs, filters...

Elasticsearch mappings and text analysis: field types, analyzers and dynamic mapping

Master Elasticsearch mappings: field types (text, keyword, numeric, date, ip, nested), multi-fiel...

Fluent Bit: parsers and filters, structuring and transforming logs

Structure and transform logs in Fluent Bit: parsers (json, regex, logfmt, ltsv), multiline parser...

Kibana: role, installation and first steps

What Kibana is in the Elastic suite, how to install it with Elasticsearch (start-local, Docker), ...

Logstash: filters, grok and dissect

Written version of the video lessons: essential filters (mutate, date, json, kv, drop), the grok ...

Fluent Bit: pipeline, configuration and essential plugins

Fluent Bit concepts (inputs, parsers, filters, tags and match, buffer, outputs), YAML configurati...

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!