Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fluentd nginx conf file for httpRequest proto logs (/etc/google-fluentd/config.d/nginx.conf)
<source>
@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
</source>
<source>
@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
</source>
<filter nginx-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['remote'], "serverIp" => record['host'], "referer" => record['referer'], "latency" => record['latency'] + "s" } }
logging.googleapis.com/trace ${record['http_x_cloud_trace_context']}
logging.googleapis.com/spanId ${record['span_id']}
</record>
remove_keys method, path, response_size, code, agent, remote, host, referer, latency, http_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