Last active
March 6, 2017 09:04
-
-
Save stuart-warren/5635613 to your computer and use it in GitHub Desktop.
Apache2 logging config to output JSON in Logstash json_event format
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
# Create a log format called 'logstash_json' that emits, in json, the parts of an http | |
# request I care about. For more details on the features of the 'LogFormat' | |
# directive, see the apache docs: | |
# http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats | |
# http://cookbook.logstash.net/recipes/apache-json-logs/ | |
LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@message\": \"%m %H %U%q %s\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"protocol\": \"%H\", \"referrer\": \"%{Referer}i\", \"user-agent\": \"%{User-agent}i\" } }" logstash_json | |
# Apache 2.4 adds sub-second precision logging | |
# http://httpd.apache.org/docs/2.4/mod/mod_log_config.html#formats | |
# LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S}t.%{msec_frac}t%{%z}t\", \"@message\": \"%m %H %U%q %s\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"protocol\": \"%H\", \"referrer\": \"%{Referer}i\", \"user-agent\": \"%{User-agent}i\" } }" logstash_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment