write filebeat config for modsecurity logs at /var/log/modsecurity/audit.log and tell…
- User
write filebeat config for modsecurity logs at /var/log/modsecurity/audit.log and tell how to configure and run filebeat
/var/log/modsecurity/audit.log contents: ... ModSecurity: Access denied with code 403 (phase 1). Matched "Operator
Rx' with parameter^10.100.2.8$' against variableREMOTE_ADDR' (Value:192.168.250.6' ) [file "/etc/nginx/modsec/custom-rules/ip-whitelist.conf"] [line "2"] [id "160001"] [rev ""] [msg "Access denied"] [data ""] [severity "0"] [ver ""] [maturity "0"] [accuracy "0"] [hostname "10.100.2.2"] [uri "/DVWA/vulnerabilities/javascript/"] [unique_id "174792867942.087195"] [ref "o0,33o6,27v4,33v0,13"] ...logstash filter:
input { beats { port => 5044 # no codec multiline here unless Filebeat is not doing it, # but better to do multiline in Filebeat } }
filter { grok { match => { "message" => "^ModSecurity:\s*%{GREEDYDATA:modsec_message}\s*(?:[(?.*)])$" } tag_on_failure => ["grok_prefix_failed"] }
if "_grokparsefailure" not in [tags] and [rest] { kv { source => "rest" field_split => "] [" value_split => " " trim_key => " \t" trim_value => """ include_brackets => false value_split_pattern => " " } } }
output { elasticsearch { hosts => ["http://localhost:9200"] index => "modsecurity-%{+YYYY.MM.dd}" } stdout { codec => rubydebug } }
- Assistant