Skip to content

Instantly share code, notes, and snippets.

@salrashid123
Last active December 31, 2018 18:37
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/6560b1297b3ddf60d2675f6fa8c925a5 to your computer and use it in GitHub Desktop.
Save salrashid123/6560b1297b3ddf60d2675f6fa8c925a5 to your computer and use it in GitHub Desktop.
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