Complete the code to define the input plugin in a Logstash configuration.
input {
[1] {
port => 5044
}
}The beats plugin is used here to listen on port 5044 for Beats input.
Complete the code to filter logs by adding a grok filter in Logstash.
filter {
[1] {
match => { "message" => "%{COMMONAPACHELOG}" }
}
}The grok filter parses unstructured log data into structured fields.
Fix the error in the output plugin to send data to Elasticsearch.
output {
elasticsearch {
hosts => ["[1]"]
index => "weblogs-%{+YYYY.MM.dd}"
}
}The hosts option requires the host and port in the format "host:port".
Fill both blanks to create a Logstash configuration that reads from a file and outputs to stdout.
input {
[1] {
path => "/var/log/syslog"
start_position => "beginning"
}
}
output {
[2] {
codec => rubydebug
}
}The file input reads log files, and stdout outputs to the console.
Fill all three blanks to create a Logstash filter that adds a tag if the response code is 404.
filter {
if [response] [1] 404 {
[2] {
add_tag => ["[3]"]
}
}
}The condition checks if the response code equals 404, then the mutate filter adds the tag 'not_found'.