Last active
October 9, 2015 12:17
-
-
Save HaVonTe1/f3dcbd7ff2386d9b1660 to your computer and use it in GitHub Desktop.
logstash for mongostats
This file contains hidden or 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
filter { | |
if [type] == "mongostat" { | |
grok { | |
patterns_dir => "/etc/logstash/patterns" | |
match => ["message","%{HOSTNAME:host}:%{INT:port} %{INSERT}%{QUERY}%{UPDATE}%{DELETE}%{GETMORE}%{SPACE}%{NUMBER:mongoCommand}\|%{NUMBER:mongoReplCommand}%{SPACE}%{NUMBER:mongoDirty}%{SPACE}%{NUMBER:mongoUsed}%{SPACE}%{NUMBER:mongoFlushes}%{SIZE}%{RES}%{SPACE}%{NUMBER:mongoQR}\|%{NUMBER:mongoQW}%{SPACE}%{NUMBER:mongoAR}\|%{NUMBER:mongoAW}%{NETIN}%{NETOUT}%{SPACE}%{NUMBER:mongoConnections}%{SPACE}%{NOTSPACE:mongoReplSet}%{SPACE}%{WORD:mongoReplMember}%{SPACE}%{TIME:mongoTime}"] | |
} | |
if [mongoNetInQualifier] == 'b' { | |
ruby { | |
code => "event['mongoNetInKB'] = event['mongoNetIn'].to_f / 1024" | |
} | |
} | |
if [mongoNetInQualifier] == 'k' { | |
ruby { | |
code => "event['mongoNetInKB'] = event['mongoNetIn'].to_f * 1" | |
} | |
} | |
if [mongoNetInQualifier] == 'm' { | |
ruby { | |
code => "event['mongoNetInKB'] = event['mongoNetIn'].to_f * 1024" | |
} | |
} | |
if [mongoNetInQualifier] == 'g' { | |
ruby { | |
code => "event['mongoNetInKB'] = event['mongoNetIn'].to_f * 1048576" | |
} | |
} | |
mutate { | |
convert => { "mongoAW" => "integer" } | |
convert => { "mongoAR" => "integer" } | |
convert => { "mongoDirty" => "float" } | |
convert => { "mongoSize" => "float" } | |
convert => { "mongoUpdate" => "integer" } | |
convert => { "mongoInsert" => "integer" } | |
convert => { "port" => "integer" } | |
convert => { "mongoNetIn" => "integer" } | |
convert => { "mongoQR" => "integer" } | |
convert => { "mongoConnections" => "integer" } | |
convert => { "mongoRes" => "float" } | |
convert => { "mongoGetmore" => "integer" } | |
convert => { "mongoCommand" => "integer" } | |
convert => { "mongoQuery" => "integer" } | |
convert => { "mongoDelete" => "integer" } | |
convert => { "mongoUsed" => "float" } | |
convert => { "mongoNetOut" => "integer" } | |
convert => { "mongoFlushes" => "integer" } | |
} | |
} | |
} |
This file contains hidden or 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 => "/tmp/mongostat.short" | |
type => "mongostat" | |
} | |
} | |
This file contains hidden or 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
#!/bin/bash | |
mongostat --authenticationDatabase admin -u admin -p secret --noheaders --all --discover -n 50 > /tmp/mongostat.short |
This file contains hidden or 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 [type] == "mongostat" { | |
elasticsearch { | |
host => "elastic-host" | |
protocol => http | |
index => "logstash-mongostat-%{+YYYY.MM.dd}" | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment