Updated May 22, 2023
Introduction to Logstash stdout
stdout is the standard output data plugin of Logstash, which has its latest version launched of 3.1.4, which was made in April 2018. This plugin helps display and print the output, which is in the format of STDOUT as the resultant of the shell that executes in the Logstash pipelines’ background. After the data is passed through the processes of ingestion and filtering, it makes the provision and allowance of accessing the events instantly, making the process of debugging the configurations of plugins easier and more convenient.
In this article, we will look at what logstash stdout is and study its subtopics, including What logstash stdout is and how to use it and Logstash stdout and Logstash stdout command, Logstash stdout plugins, and a Conclusion about the same.
What is Logstash stdout?
To print the output, which is in the format of STDOUT, to the shell of the Logstash, we can use the simple plugin available in Logstash named stdout. Whenever there is a need to debug the working and execution of the plugin and its configurations, the stdout plugin’s output is of great help. Moreover, after the event data passes through various filters and the inputs, enabling access to the event data is done by Logstash, which makes it helpful in the debugging process.
How to use Logstash stdout?
Let us consider one example to understand how the configuration of the output plugin to stdout proves helpful. Viewing the output results of pipelines inside the event that are used while performing quick iteration uses the following output configuration and the -e command option available in Logstash.
Output {
Stdout {}
}
When the above output configuration is used in ruby-debug, which is done by default when using codec in the standard output plugin of Logstash along with the library name awesome_print of ruby gives the result as the output of event data.
When the stdout mentions the codec as json, the output results in the structured event data format in JSON format. The configuration of stdout in the case of json should be set as below to get the event data in JSON structured format –
Output {
Stdout {codec => json}
}
Logstash stdout command
The logstash-stdout command is used for printing the event and its data o the standard output, and the complete details can be acquired in the git repository of Logstash-output-stdout, which can be found on this link.
Let us consider a sample example of the configuration file contents of the pipeline.conf file when used for implementing multiple outputs in it –
input {
linkedIn {
consumer_key => "sampleEducbaConsumerKey"
consumer_secret => "sampleEducbaSecret"
keywords => ["business"]
oauth_token => "sampleEducbaAccessToken"
oauth_token_secret => "sampleEducbaAccessTokenSecret"
}
beats {
port => "5432"
}
}
output {
stdout
{
codec => json_lines {}
}
elasticsearch {
hosts => [“sample Ip address: port number”]
}
file {
codec => json_lines {}
path => "/educba/sample/filepath"
}
}
Now, to verify whether the configurations are set as expected, we can execute the following command –
bin/Logstash -f pipeline.conf --config.test_and_exit
Execution of the above command gives the following output –
Logstash stdout plugins
We can use Logstash stdout by specifying the same in the pipeline configuration file.cnf. Along with that, we can even go for specifying various options related to configurations. The below table contains the list of all the supported configuration options for the stdout plugin –
Configuration option setting | Type of input data | Optional/ Required |
Id | String value | Optional |
Enable_metric | Boolean | Optional |
Codec | Codec | Optional |
Codec – The codec configuration setting accepts the input of type codec and, when not specified, contains the default value as rubydebug. This is used for the process of getting the correct output data. The codec configuration setting in output acts as the technique to encode the data before the departure of output. While doing so, it is not even necessary to segregate the filters inside the pipelines of Logstash.
Id – This configuration setting option accepts the string value and, by default, when not specified, does not contain any value. When specified, it should be a unique identifier for the plugin. When we do not specify any value for this configuration setting, it will result in internal automated value generation by Logstash. It is always a good practice to mention the value of id in our configurations. If there are two or more multiple plugins of the same type, it will be useful for identifying each one individually. Let us consider an example in case we have two outputs of stdout. Using the specification of the id value for both plugins will be useful for Logstash in the monitoring process when we use API of monitoring. The sample of specification of id for stdout plugin is as shown below-
Output {
Stdout{
Id => “sample_educba_plugin_identifier”
}
}
Please note that when going for the variable substitution of the configuration setting of id, it will only provide the support for the environment variables and not the personal store values.
Enable_metric – It accepts the Boolean value and, when not specified, contains the default value of true. When we specify this configuration setting option, we can enable or disable metrics logging corresponding to a particular plugin. For example, the default behavior of the Logstash is such that it keeps track and records all the metrics; however, we can disable this behavior for the particular plugin(s) if we want.
Conclusion
Logstash stdout plugin is used for printing the event’s data to the standard output. We can even use configuration setting options such as id, codec, or enable_metric, which help define the details of the plugin. We can even print the event data in standard output in the format of JSON structured data when we set the codec to json.
Recommended Articles
This is a guide to Logstash Stdout. Here we discuss Logstash stdout and study its subtopics, including What stdout is. You may also look at the following articles to learn more –