Last active
September 3, 2022 18:25
-
-
Save devops-school/fcced456b7ea2af027017154b47efe9f to your computer and use it in GitHub Desktop.
Elastic Logstash Input Filter and Output Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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