Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fluentd nginx conf file for httpRequest proto logs (/etc/google-fluentd/config.d/nginx.conf)
@type tail
format nginx
path /var/log/nginx/access.log
pos_file /var/lib/google-fluentd/pos/nginx-access.pos
read_from_head true
tag nginx-access
@type tail
format none
path /var/log/nginx/error.log
pos_file /var/lib/google-fluentd/pos/nginx-error.pos
read_from_head true
tag nginx-error
<filter nginx-access>
@type record_transformer
enable_ruby true
httpRequest ${ {"requestMethod" => record['method'], "requestUrl" => record['path'], "responseSize" => record['response_size'], "status" => record['code'], "userAgent" => record['agent'], "remoteIp" => record['remote'], "serverIp" => record['host'], "referer" => record['referer'], "latency" => record['latency'] + "s" } } ${record['http_x_cloud_trace_context']} ${record['span_id']}
remove_keys method, path, response_size, code, agent, remote, host, referer, latency, http_x_cloud_trace_context, span_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment