Skip to content

Instantly share code, notes, and snippets.

@devops-school
Last active September 3, 2022 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devops-school/fcced456b7ea2af027017154b47efe9f to your computer and use it in GitHub Desktop.
Save devops-school/fcced456b7ea2af027017154b47efe9f to your computer and use it in GitHub Desktop.
Elastic Logstash Input Filter and Output Example
output {
if [fieldName] == "stringA" {
output for this type of message
}
if [fieldName] == "stringB" {
output for this type of message
}
if [fieldName] == "stringN" {
output for this type of message
}
}
input {
file {
path => "/usr/share/logstash/batch_10day.txt"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ";"
columns => ["status","date", "time", "workstation", "application", "job", "Error_code"]
}
}
output {
csv {
path => "/usr/share/logstash/batch_10day.csv"
csv_options => {
"write_headers" => true
"headers" => ["status","date", "time", "workstation", "application", "job", "Error_code"]
}
fields => ["status","date", "time", "workstation", "application", "job", "Error_code"]
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "logstash_index"
}
stdout {
codec => rubydebug
}
csv {
path => "path-to-file\syslogs-%{+yyyy.MM.dd}.csv"
csv_options => {
"write_headers" => true
"headers" => ["timestamp", "message", "count"]
}
fields => ["@timestamp", "message", "count"]
}
}
# foo.conf
input {
file {
path => "C:/logstash-2.3.1/logstash-tutorial-dataset"
start_position => "beginning"
ignore_older => 0
}
}
output {
stdout {}
file {
path => "C:/output.txt"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment