For your reference, below is a list of the articles in this series.
Inputs create events, Filters modify the input events, and Outputs ship them to the destination. Inputs and outputs support codecs, enabling you to encode or decode data as it enters or exits the pipeline without the need for a separate filter.
Logstash employs in-memory bounded queues between pipeline stages by default (from Input to Filter and from Filter to Output) to buffer events. However, if Logstash terminates abruptly, any events stored in memory will be lost. To mitigate data loss, you can enable Logstash to persist in-flight events to disk by utilizing persistent queues.
To enable persistent queues, set the queue.type: persisted
property in the logstash.yml file
, located in the logstash-7.15.0/config
folder.
Viewing Installed Logstash Plugins
To see the list of currently installed Logstash plugins, use the following command:
1 | bin/logstash-plugin list |
Output:
1 | logstash-codec-avro |
Installing Logstash Plugins
To install Logstash plugins, you can use the following command:
1 | bin/logstash-plugin install logstash-output-email |
Input Plugins
Input plugins configure a set of events to be fed into Logstash, allowing you to specify one or more input sources. Here are some of the available input plugins:
1 | logstash-input-exec |
Output Plugins
Output plugins are used to send data to a destination. They offer the flexibility to configure single or multiple output sources. Some of the available output plugins are:
1 | logstash-output-lumberjack |
Filter Plugins
Filter plugins are used to transform data. You can combine multiple filter plugins, and the order in which they are applied determines the sequence of transformations. Here are some of the available filter plugins:
1 | logstash-filter-anonymize |
Codec Plugins
Codec plugins are used to encode or decode incoming or outgoing events from Logstash. Codecs can be used in input and output configurations. Input codecs decode data before it enters Logstash, and output codecs encode data before it leaves Logstash. Some of the available codec plugins include:
1 | logstash-codec-avro |
Data Types for Plugin Properties
Array:
- An array is a collection of values for a property.
- Example:
path => ["value1", "value2"]
Boolean:
- A boolean value is either
true
orfalse
(without quotes). - Example:
periodic_flush => false
- A boolean value is either
Codec:
- Codec is not a data type but a way to encode or decode data at input or output.
- Example:
codec => "json"
- This instance specifies that this codec, at output, will encode all output in JSON format.
Hash:
- A hash is a key-value pair collection specified as
"key" => "value"
. - Multiple values in a collection are separated by a space.
- Example:
1
2
3
4match => {
"key1" => "value1"
"key2" => "value2"
}
- A hash is a key-value pair collection specified as
String:
- String represents a sequence of characters enclosed in quotes.
- Example:
value => "Welcome to ELK"
Comments:
- Comments begin with the
#
character. - Example:
# This represents a comment
- Comments begin with the
Logstash Conditionals
Logstash conditionals are used to filter events or log lines under certain conditions. Conditionals in Logstash are handled like other programming languages and work with if
, if else
, and else
statements. Multiple if else
blocks can be nested.
Syntax for conditionals:
1 | if <conditional expression1> { |
Conditionals work with comparison operators, boolean operators, and unary operators:
These conditionals allow you to apply specific actions to events based on specified conditions in your Logstash configuration.
- Comparison operators include:
- Equality operators:
==
,!=
,<
,>
,<=
,>=
- Regular expressions:
=~
,!~
- Inclusion:
in
,not in
- Equality operators:
- Boolean operators include
and
,or
,nand
,xor
- Unary operators include
!
Example:
1 | filter { |
Exploring Plugin Documentation
To learn more about each of these Logstash plugins, you can visit the official documentation:
- https://www.elastic.co/guide/en/logstash/8.10/input-plugins.html
- https://www.elastic.co/guide/en/logstash/8.10/output-plugins.html
- https://www.elastic.co/guide/en/logstash/8.10/filter-plugins.html
- https://www.elastic.co/guide/en/logstash/8.10/codec-plugins.html
This concludes our simple introduction to Logstash plugins!