Last active
January 13, 2017 20:12
-
-
Save alexgalkin/f0e579eb2e9bd659ab8c45507159001a to your computer and use it in GitHub Desktop.
Logstash config for parsing DB CSV reports
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 => "/var/logs/csv/*.csv" | |
type => "csvdb" | |
start_position => "beginning" | |
} | |
} | |
filter { | |
if [message] =~ /^oid/ { | |
drop { } | |
} | |
csv { | |
skip_empty_columns => true | |
columns => ["oid", "table_schema", "table_name", "row_estimate", "total_bytes", "index_bytes", "toast_bytes", "table_bytes", "total", "index", "toast", "table"] | |
separator => "," | |
convert => { | |
"table_bytes" => "integer" | |
"index_bytes" => "integer" | |
"total_bytes" => "integer" | |
"oid" => "integer" | |
} | |
} | |
if ![toast_bytes] { | |
mutate { | |
add_field => {"toast_bytes" => 0 } | |
} | |
} | |
mutate { | |
convert => { | |
"toast_bytes" => "integer" | |
} | |
} | |
grok { | |
match => ["path", "^%{GREEDYDATA}/[^/]+_%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day}\.csv$"] | |
add_field => ["date", "%{year}_%{month}_%{day}"] | |
} | |
date { | |
match => ["date", "YYY_MM_dd"] | |
} | |
} | |
output { | |
elasticsearch { | |
action => "index" | |
hosts => "localhost" | |
index => "logstash-%{+YYYY.MM.dd}" | |
workers => 1 | |
} | |
stdout { | |
codec => rubydebug | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment