Skip to content

Instantly share code, notes, and snippets.

@fefore
Last active May 23, 2018 11:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fefore/d10b6ca96e5ef89c24b4b28253ceaac1 to your computer and use it in GitHub Desktop.
Save fefore/d10b6ca96e5ef89c24b4b28253ceaac1 to your computer and use it in GitHub Desktop.
[LOGSTASH] Grok pattern for AWS Cloudfront logs
filter {
if [cloudfront_version] {
mutate {
gsub => ["message", "\t", " "]
}
dissect {
mapping => {"message" => "%{date} %{time} %{x_edge_location} %{sc_bytes} %{clientip} %{cs_method} %{cs_host} %{cs_uri_stem} %{sc_status} %{referrer} %{agent} %{cs_uri_query} %{cookies} %{x_edge_result_type} %{x_edge_request_id} %{x_host_header} %{cs_protocol} %{cs_bytes} %{time_taken} %{x_forwarded_for} %{ssl_protocol} %{ssl_cipher} %{x_edge_response_result_type} %{cs_protocol_version}"}
convert_datatype => {
sc_bytes => "int"
sc_status => "int"
cs_bytes => "int"
time_taken => "float"
}
add_field => {"timestamp" => "%{date} %{time}"}
}
date {
match => ["timestamp", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss"]
timezone => "UTC"
}
geoip {
source => "clientip"
}
mutate {
replace => {
"type" => "cloudfront"
}
remove_field => ["timestamp","message","cloudfront_fields"]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment