-
-
Save aslacker/d3fa5ecb1c74640886557a78e62c69f2 to your computer and use it in GitHub Desktop.
Suricata Logstash Elasticsearch
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 => ["/var/log/suricata/eve.json"] | |
| sincedb_path => ["/var/lib/logstash/since.db"] | |
| codec => json | |
| type => "SuricataIDPS" | |
| } | |
| } | |
| filter { | |
| if [type] == "SuricataIDPS" { | |
| date { | |
| match => [ "timestamp", "ISO8601" ] | |
| } | |
| ruby { | |
| code => "if event['event_type'] == 'fileinfo'; event['fileinfo']['type']=event['fileinfo']['magic'].to_s.split(',')[0]; end;" | |
| } | |
| } | |
| if [src_ip] { | |
| geoip { | |
| source => "src_ip" | |
| target => "src_geoip" | |
| database => "/opt/logstash/vendor/geoip/GeoLiteCity.dat" | |
| } | |
| mutate { | |
| add_field => { "src_ip_rdns" => "%{src_ip}" } | |
| } | |
| dns { | |
| reverse => [ "src_ip_rdns" ] | |
| action => "replace" | |
| } | |
| } | |
| if [dest_ip] { | |
| geoip { | |
| source => "dest_ip" | |
| target => "dest_geoip" | |
| database => "/opt/logstash/vendor/geoip/GeoLiteCity.dat" | |
| } | |
| mutate { | |
| add_field => { "dest_ip_rdns" => "%{dest_ip}" } | |
| } | |
| dns { | |
| reverse => [ "dest_ip_rdns" ] | |
| action => "replace" | |
| } | |
| } | |
| #if [dest_port] and [proto] and ([proto] == "TCP" or [proto] == "UDP"){ | |
| # ruby { | |
| # code => "require 'socket'; event['dest_service'] = Socket::getservbyport(event['dest_port'], event['proto'].downcase)" | |
| # } | |
| #} | |
| } | |
| output { | |
| elasticsearch { | |
| hosts => ["localhost"] | |
| index => "logstash-suricata-%{+YYYY.MM.dd}" | |
| template => "/etc/logstash/templates/suricata_template.json" | |
| template_overwrite => true | |
| } | |
| } |
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
| { | |
| "template" : "logstash-suricata-*", | |
| "settings" : { | |
| "index.refresh_interval" : "5s" | |
| }, | |
| "mappings" : { | |
| "_default_" : { | |
| "_all" : {"enabled" : true, "omit_norms" : true}, | |
| "dynamic_templates" : [ { | |
| "message_field" : { | |
| "match" : "message", | |
| "match_mapping_type" : "string", | |
| "mapping" : { | |
| "type" : "string", "index" : "analyzed", "omit_norms" : true, | |
| "fielddata" : { "format" : "disabled" } | |
| } | |
| } | |
| }, { | |
| "string_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "string", | |
| "mapping" : { | |
| "type" : "string", "index" : "analyzed", "omit_norms" : true, | |
| "fielddata" : { "format" : "disabled" }, | |
| "fields" : { | |
| "raw" : {"type": "string", "index" : "not_analyzed", "doc_values" : true, "ignore_above" : 256} | |
| } | |
| } | |
| } | |
| }, { | |
| "float_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "float", | |
| "mapping" : { "type" : "float", "doc_values" : true } | |
| } | |
| }, { | |
| "double_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "double", | |
| "mapping" : { "type" : "double", "doc_values" : true } | |
| } | |
| }, { | |
| "byte_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "byte", | |
| "mapping" : { "type" : "byte", "doc_values" : true } | |
| } | |
| }, { | |
| "short_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "short", | |
| "mapping" : { "type" : "short", "doc_values" : true } | |
| } | |
| }, { | |
| "integer_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "integer", | |
| "mapping" : { "type" : "integer", "doc_values" : true } | |
| } | |
| }, { | |
| "long_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "long", | |
| "mapping" : { "type" : "long", "doc_values" : true } | |
| } | |
| }, { | |
| "date_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "date", | |
| "mapping" : { "type" : "date", "doc_values" : true } | |
| } | |
| }, { | |
| "geo_point_fields" : { | |
| "match" : "*", | |
| "match_mapping_type" : "geo_point", | |
| "mapping" : { "type" : "geo_point", "doc_values" : true } | |
| } | |
| } ], | |
| "properties" : { | |
| "@timestamp": { "type": "date", "doc_values" : true }, | |
| "@version": { "type": "string", "index": "not_analyzed", "doc_values" : true }, | |
| "dest_geoip" : { | |
| "type" : "object", | |
| "dynamic": true, | |
| "properties" : { | |
| "ip": { "type": "ip", "doc_values" : true }, | |
| "location" : { "type" : "geo_point", "doc_values" : true }, | |
| "latitude" : { "type" : "float", "doc_values" : true }, | |
| "longitude" : { "type" : "float", "doc_values" : true } | |
| } | |
| }, | |
| "src_geoip" : { | |
| "type" : "object", | |
| "dynamic": true, | |
| "properties" : { | |
| "ip": { "type": "ip", "doc_values" : true }, | |
| "location" : { "type" : "geo_point", "doc_values" : true }, | |
| "latitude" : { "type" : "float", "doc_values" : true }, | |
| "longitude" : { "type" : "float", "doc_values" : true } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment