Skip to content

Instantly share code, notes, and snippets.

@jemacom
Created September 2, 2015 15:19
Show Gist options
  • Save jemacom/aed7f03c400618d107a8 to your computer and use it in GitHub Desktop.
Save jemacom/aed7f03c400618d107a8 to your computer and use it in GitHub Desktop.
Logstash conf file to parse pfsense logs
input {
syslog {
type => "pfsense"
}
}
filter {
if [type] == "pfsense" {
grok {
patterns_dir => "/opt/logstash/patterns"
match => [
"message", "%{PFSENSE}" ]
}
if [prog] == "filterlog" {
grok {
patterns_dir => "/opt/logstash/patterns"
match => [ "msg", "%{LOG_DATA}%{IP_SPECIFIC_DATA}%{IP_DATA}%{PROTOCOL_DATA}" ]
}
geoip {
#database => "/opt/logstash/GeoLiteCity.dat"
source => "src_ip"
target => "geoip"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float" ]
remove_tag => [ "_grokparsefailure" ]
}
}
}
}
output {
stdout { codec => dots }
elasticsearch {
protocol => "http"
host => "elkserver"
cluster => "mycluster"
index => "pfsense-logs-%{+dd.MM.YYYY}"
#index => "pfsense-logs"
}
if "ntopng" in [message] {
stdout { codec => rubydebug }
email {
options => [
"smtpIporHost" , "mail.iptech-group.com",
"port" , "26",
"userName" , "log@iptech-group.com",
"password", "P@ssword",
"authenticationType" , "login"
]
from => "<log@iptech-group.com>"
cc => "<chokri.benjmaa@gmail.com>"
to => "<jemacomchokri@gmail.com>"
subject => "Logstash alert (TEST) "
htmlbody => "
<html>
<body>
<table border=\"1\">
<tbody>
<tr bgcolor=\"#99FF66\">
<td>Pfsense email emergency report :</td>
</tr>
<tr bgcolor=\"#FF6600\">
<td>ERROR </td>
<td> ntopn fails to start %{date} at host %{host}</td>
<td> %{msg}</td>
</tr>
</tbody>
</table>
</body></html>
"
via => "smtp"
}
}
if "flooder" in [message]{
stdout { codec => rubydebug }
email {
via => "smtp"
options => [
"smtpIporHost" , "mail.iptech-group.com",
"port" , "26",
"userName" , "log@iptech-group.com",
"password", "P@ssword",
"authenticationType" , "login"
]
from => "<log@iptech-group.com>"
to => "<jemacomchokri@gmail.com>"
subject => "Logstash alert (TEST) "
htmlbody => "
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" style=\"font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;\">
<body>
<table border=\"1\">
<tbody>
<tr bgcolor=\"#99FF66\">
<td>Pfsense email emergency report :</td>
</tr>
<tr bgcolor=\"#FF6600\">
<td>ERROR </td>
<td> ntopn fails to start %{date} at host %{host}</td>
<td> %{msg}</td>
</tr>
</tbody>
</table>
</body></html>
"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment