Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Last active December 31, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salrashid123/8e0e8c610475ac9fd893c80325d5fc3a to your computer and use it in GitHub Desktop.
Save salrashid123/8e0e8c610475ac9fd893c80325d5fc3a to your computer and use it in GitHub Desktop.
Fluentd apache conf file for httpRequest proto logs (/etc/google-fluentd/config.d/apache.conf)
<source>
@type tail
format apache2
path /var/log/apache*/access.log,/var/log/apache*/access_log,/var/log/httpd/access.log,/var/log/httpd/access_log
pos_file /var/lib/google-fluentd/pos/apache-access.pos
read_from_head true
tag apache-access
</source>
<source>
@type tail
format none
path /var/log/apache*/error.log,/var/log/apache*/error_log,/var/log/httpd/error.log,/var/log/httpd/error_log
pos_file /var/lib/google-fluentd/pos/apache-error.pos
read_from_head true
tag apache-error
</source>
<filter apache-access>
@type record_transformer
enable_ruby true
<record>
httpRequest ${ {"requestMethod" => record['method'], "requestUrl" => record['path'], "responseSize" => record['response_size'], "status" => record['code'], "userAgent" => record['agent'], "remoteIp" => record['host'], "referer" => record['referer'], "latency" => record['latency'] + "s" } }
logging.googleapis.com/trace ${record['x_cloud_trace_context']}
logging.googleapis.com/spanId ${record['span_id']}
</record>
remove_keys method, path, response_size, code, agent, host, referer, latency, x_cloud_trace_context, span_id
</filter>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment