Logstash uses pipelines to collect and process data. You must configure input and output plug-ins for pipelines. You can configure filter plug-ins based on your business requirements. The input and output plug-ins are used to configure input and output data sources, and the filter plug-ins are used to preprocess collected data. This topic describes pipeline configuration files of Alibaba Cloud Logstash.
For more information, see Structure of a Config File in open source Logstash documentation.
You can use a Logstash configuration file to configure a pipeline for data collection and processing. For more information, see Use configuration files to manage pipelines.
Configuration file structure
input {
...
}
filter {
...
}
output {
...
}
Each part can contain one or more plug-ins. If you specify multiple filter plug-ins, Logstash applies the plug-ins in the order that they appear in the configuration file.
- If the configuration file contains a parameter similar to last_run_metadata_path, you must set this parameter to the file path of Alibaba Cloud Logstash. A path in the
/ssd/1/<Logstash cluster ID>/logstash/data/
format is provided at the backend and is available for tests. The system does not delete the data in this path. Make sure that your disk has sufficient storage space when you use this path. After you specify a path, Logstash automatically generates a file in the path, but you cannot view the data in the file. - For security purposes, if you specify a JDBC driver when you configure a pipeline, you must add
allowLoadLocalInfile=false&autoDeserialize=false
at the end of the jdbc_connection_string parameter, such asjdbc_connection_string => "jdbc:mysql://xxx.drds.aliyuncs.com:3306/<Database name>?allowLoadLocalInfile=false&autoDeserialize=false"
. Otherwise, when you add a configuration file for the Logstash pipeline, the system displays an error message that indicates a check failure.
Plug-in configuration
input {
beats {
port => 8000
host => "118.11.xx.xx"
}
beats {
port => 8001
host => "192.168.xx.xx"
}
}
The properties supported by different plug-ins vary based on the plug-in types. For more information, see Input plugins, Output plugins, Filter plugins, and Codec plugins.
Value types
When you configure a plug-in, you can set the following types of values.
Array
:list => true
property to facilitate type checks. This type is used when you want to process hash tables or lists of mixed types that do not require type checks. Example: users => [ {id => 1, name => bob}, {id => 2, name => jane} ]
List
:list => true
when you declare a parameter, the plug-in enables list checks. Example: path => [ "/var/log/messages", "/var/log/*.log" ]
uris => [ "http://elastic.co", "http://example.net" ]
In this example, path is configured as a list that contains two strings. uris is configured as a list of URLs. If one of the URLs is invalid, event processing fails.
Boolean
ssl_enable => true
Byte
my_bytes => "1113" # 1113 bytes
my_bytes => "10MiB" # 10485760 bytes
my_bytes => "100kib" # 102400 bytes
my_bytes => "180 mb" # 180000000 bytes
Codec
A codec is a type of data that is encoded or decoded. It can be used in both the input and output plug-ins. An input codec decodes data before the data enters the input plug-in. An output codec encodes data before the data leaves the output plug-in. If you use an input or output codec, you do not need to specify filter plug-ins for your Logstash pipeline.
codec => "json"
Hash
A value of the hash type is a collection of key-value pairs, such as "field1" => "value1"
.
match => {
"field1" => "value1"
"field2" => "value2"
...
}
# Specify key-value pairs in a single line. Separate the key-value pairs with spaces instead of commas (,).
match => { "field1" => "value1" "field2" => "value2" }
Numeric
port => 33
Password
my_password => "password"
URI
http://user:paas@example.net
, the password is not recorded or displayed. Example: my_uri => "http://foo:bar@example.net"
Path
my_path => "/tmp/logstash"
String
A string must be a single sequence of characters enclosed in double quotation marks (") or single quotation marks (').
Escape sequence
config.support_escapes: true
in logstash.yml. Then, the quoted strings (double- and single-precision) are converted based on the following table. Escape character | Description | ASCII value (decimal) |
---|---|---|
\r | Carriage return | 013 |
\n | Line break | 010 |
\t | Tab | 009 |
\\ | Backslash | 092 |
\" | Double quotation mark | 034 |
\' | Single quotation mark | 039 |
name => 'It\'s a beautiful day'
Comment
#
) and do not need to be at the beginning of a line. Example: # A comment.
input { # A comment.
# ...
}